Skip to content

Add new dotnet tool packages Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm#121282

Closed
Copilot wants to merge 17 commits intomainfrom
copilot/fix-9141961-210716005-ba7fcf33-0366-4343-adba-5ef567bc9850
Closed

Add new dotnet tool packages Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm#121282
Copilot wants to merge 17 commits intomainfrom
copilot/fix-9141961-210716005-ba7fcf33-0366-4343-adba-5ef567bc9850

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Fixes #13823

Status: Implementation Complete ✅

Successfully implemented RID-specific tool packages for Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm as new separate packages, following the design at https://github.com/dotnet/designs/blob/main/accepted/2025/rid-specific-tool-packages.md.

Important: The existing Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm packages remain unchanged as content packages to avoid breaking downstream consumers.

Implementation

New Dotnet Tool Packages (Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm)

  • Configured as DotnetTool package type
  • RID-specific packages include native binaries in tools/net10.0/<rid>/
  • Primary packages dynamically generate tool manifest with $(PackageVersion) substitution
  • Hardcoded RID list to support distributed builds across multiple machines
  • TargetRid entry with Exclude pattern for automatic community platform support
  • Separate from existing packages - no breaking changes to Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm

Existing Packages Preserved (Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm)

  • Remain as content packages in their original format
  • No breaking changes for existing consumers
  • Continue to work as before for projects using Microsoft.NET.Sdk.IL and other SDK consumers

Tool Manifests

  • DotnetToolSettings.xml - RID-specific package manifest with executable runner type
  • Primary manifest generated dynamically during build to use current $(PackageVersion)
  • Includes all supported RIDs including community platforms (FreeBSD)
  • Automatically includes $(TargetRid) using Exclude="@(_OfficialRID)" pattern

Package Names and Commands

  • Package: Microsoft.dotnet-ilasm → Command: dotnet-ilasm
  • Package: Microsoft.dotnet-ildasm → Command: dotnet-ildasm

Supported RIDs

  • Windows: win-x64, win-x86, win-arm64
  • Linux: linux-x64, linux-arm, linux-arm64, linux-musl-x64, linux-musl-arm64
  • macOS: osx-x64, osx-arm64
  • Community platforms: freebsd-x64, freebsd-arm64
  • Plus any $(TargetRid) not in the official list (automatically excluded if duplicate)

Package Structure

Primary Packages (Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm):

tools/net10.0/any/DotnetToolSettings.xml (generated with RID list and current version)

RID-Specific Packages (e.g., runtime.linux-x64.Microsoft.dotnet-ilasm):

tools/net10.0/linux-x64/DotnetToolSettings.xml
tools/net10.0/linux-x64/ilasm

RID-Specific Packages (e.g., runtime.linux-x64.Microsoft.dotnet-ildasm):

tools/net10.0/linux-x64/DotnetToolSettings.xml
tools/net10.0/linux-x64/ildasm

Benefits

  • ✅ Smaller downloads (only RID-specific package for current platform is downloaded)
  • ✅ No managed wrapper overhead - native binaries run directly
  • ✅ Native performance with executable runner type
  • ✅ Consistent with .NET tool packaging design
  • ✅ No hardcoded versions - automatically uses build system version
  • ✅ Works in distributed build environments (different RIDs on different machines)
  • ✅ Includes community platform support (FreeBSD)
  • Automatically supports new community RIDs via $(TargetRid) with simple Exclude pattern
  • ✅ Clear usage documentation in package descriptions
  • Simple, maintainable implementation following ILCompiler pattern
  • Both ILAsm and ILDAsm now available as dotnet tools
  • Existing packages unchanged - no breaking changes for downstream consumers

Verification

New dotnet-ilasm package:

  • Package ID: Microsoft.dotnet-ilasm
  • Command: dotnet-ilasm
  • Supports RID-specific tool package pattern
  • No conflicts with existing Microsoft.NETCore.ILAsm package

New dotnet-ildasm package:

  • Package ID: Microsoft.dotnet-ildasm
  • Command: dotnet-ildasm
  • Supports RID-specific tool package pattern
  • No conflicts with existing Microsoft.NETCore.ILDAsm package

Existing packages preserved:

  • Microsoft.NETCore.ILAsm - unchanged content package format
  • Microsoft.NETCore.ILDAsm - unchanged content package format

Usage

dotnet-ilasm

# Install the tool (uses new package name)
dotnet tool install -g Microsoft.dotnet-ilasm

# Invoke the tool (uses new command name)
dotnet-ilasm mycode.il -dll -output:myassembly.dll

# Get help
dotnet-ilasm -?

dotnet-ildasm

# Install the tool (uses new package name)
dotnet tool install -g Microsoft.dotnet-ildasm

# Invoke the tool (uses new command name)
dotnet-ildasm myassembly.dll

# Get help
dotnet-ildasm -?

Building Locally

# Build CoreCLR runtime and packages
./build.sh -subset clr.runtime+clr.packages -c Release

# Or build just the packages if runtime is already built
./build.sh -subset clr.packages -c Release

Packages will be in: artifacts/packages/Release/Shipping/


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 3, 2025
Copilot AI changed the title [WIP] Update the ilasm package to publish ilasm a dotnet tool Add dotnet tool support to Microsoft.NETCore.ILAsm package Nov 3, 2025
Copilot AI requested a review from jcouv November 3, 2025 01:33
@@ -0,0 +1,167 @@
// Licensed to the .NET Foundation under one or more agreements.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - I'll update the implementation to use RID-specific tool packages instead of a managed wrapper. This will eliminate the wrapper and directly use the native ilasm binary as the entry point with the executable runner type as described in the design document.

@jcouv
Copy link
Member

jcouv commented Nov 4, 2025

@copilot src/coreclr/tools/dotnet-ilasm/dotnet-ilasm.csproj:6

Could we instead use .NET 6.0 as TargetFramework and the RollForward attribute, as explained in https://andrewlock.net/using-and-authoring-dotnet-tools/#ensuring-compatibility-by-multi-targeting ? #Closed

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot src/coreclr/tools/dotnet-ilasm/dotnet-ilasm.csproj:6

Could we instead use .NET 6.0 as TargetFramework and the RollForward attribute, as explained in https://andrewlock.net/using-and-authori...

Since we're switching to RID-specific tool packages based on @jkotas's feedback, there won't be a managed wrapper anymore - the native ilasm binary will be the entry point directly. The target framework concern will no longer apply. #Closed

Copilot AI changed the title Add dotnet tool support to Microsoft.NETCore.ILAsm package [WIP] Investigate RID-specific tool packages for Microsoft.NETCore.ILAsm Nov 4, 2025
@jcouv
Copy link
Member

jcouv commented Nov 4, 2025

@copilot Please proceed with the next steps you listed

Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot Please proceed with the next steps you listed

Implemented RID-specific tool packages in commit 5b66f25. The solution:

  • Creates RID-specific packages (e.g., runtime.linux-x64.Microsoft.NETCore.ILAsm) with native ilasm binary as direct entry point
  • Primary package (Microsoft.NETCore.ILAsm) includes tool manifest referencing all RID-specific packages
  • Uses executable runner type - no managed wrapper needed
  • Verified working: tool installs and executes ilasm successfully

The packages can now be installed with dotnet tool install -g Microsoft.NETCore.ILAsm and the native ilasm binary runs directly without any wrapper overhead.

Copilot AI changed the title [WIP] Investigate RID-specific tool packages for Microsoft.NETCore.ILAsm Implement RID-specific tool packages for Microsoft.NETCore.ILAsm Nov 4, 2025
@am11
Copy link
Member

am11 commented Nov 4, 2025

Should ildasm be also packed as tool?

ps - it's sad that single package doesn't support multiple commands dotnet/sdk#16708, otherwise we could have Microsoft.NETCore.ILTools with both ilasm and ildasm packed together.

Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot Change of plans... The conversion from a content package to a dotnet-tool package breaks downstream consumers.
Let's put the existing packages back the way they were and introduce separate p...

Implemented in 5de2013. Created new separate packages:

New Packages:

  • Microsoft.dotnet-ilasm (command: dotnet-ilasm)
  • Microsoft.dotnet-ildasm (command: dotnet-ildasm)

Existing Packages:

  • Microsoft.NETCore.ILAsm - reverted to original content package format
  • Microsoft.NETCore.ILDAsm - reverted to original content package format

This approach avoids breaking existing consumers that use the packages as content packages while providing new dotnet tool packages with the requested naming.

Copilot AI changed the title Implement RID-specific tool packages for Microsoft.NETCore.ILAsm and ILDAsm Add new dotnet tool packages Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm Nov 11, 2025
Copilot AI requested a review from jcouv November 11, 2025 05:31
@jcouv
Copy link
Member

jcouv commented Nov 11, 2025

@copilot Can we use PackAsTool functionality and avoid manual package creation (why we have to create your own dotnet tool settings.xml files?)

Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot Can we use PackAsTool functionality and avoid manual package creation (why we have to create your own dotnet tool settings.xml files?)

The manual DotnetToolSettings.xml files are necessary because ilasm and ildasm are native binaries, not managed .NET assemblies. PackAsTool only works for managed executables (C# projects).

For native binaries, we need to:

  1. Use runner="executable" in the manifest (instead of the default dotnet runner for managed tools)
  2. Manually create RID-specific packages with the native binaries
  3. Follow the RID-specific tool packages design (https://github.com/dotnet/designs/blob/main/accepted/2025/rid-specific-tool-packages.md)

This is the same approach used by other native tools in the .NET ecosystem that need to be packaged as dotnet tools.

<_OfficialRID Include="linux-musl-arm64" />
<_OfficialRID Include="osx-x64" />
<_OfficialRID Include="osx-arm64" />
<_OfficialRID Include="freebsd-x64" />
Copy link
Member

@jkotas jkotas Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

freebsd RID is not necessary here per earlier discussion #Resolved

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.Build.Traversal">
<PropertyGroup>
<IsILToolPackage>true</IsILToolPackage>
Copy link
Member

@jkotas jkotas Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the IsILToolPackage property for? Delete it? (It can be deleted from the existing project files as well.) #Resolved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove it, things build fine locally in a local build.

Apparently, the property only matters in specific cross-compilation scenarios when BuildHostILTools=true, which is used during certain infrastructure builds where you need the tool for a different architecture than the target.
Since the existing project files have it, I think it's safer to keep.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new dotnet tool packages Microsoft.dotnet-ilasm and Microsoft.dotnet-ildasm that provide RID-specific native tool packages following the design pattern used by ILCompiler. These are separate from and do not replace the existing Microsoft.NETCore.ILAsm and Microsoft.NETCore.ILDAsm content packages.

Key changes:

  • New RID-specific dotnet tool packages with native binaries and dynamic manifest generation
  • Publishing configuration for artifact distribution in VMR builds
  • Hardcoded RID lists with automatic $(TargetRid) inclusion for community platform support

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/coreclr/.nuget/coreclr-packages.proj Adds project references for the two new dotnet tool packages
src/coreclr/.nuget/Microsoft.dotnet-ilasm/Microsoft.dotnet-ilasm.proj Traversal project configuration for ilasm tool package with IsILToolPackage property
src/coreclr/.nuget/Microsoft.dotnet-ilasm/Microsoft.dotnet-ilasm.pkgproj Package project with metadata, RID-specific binary inclusion, and dynamic manifest generation for ilasm
src/coreclr/.nuget/Microsoft.dotnet-ilasm/DotnetToolSettings.xml Tool manifest for RID-specific ilasm packages defining command name and executable runner
src/coreclr/.nuget/Microsoft.dotnet-ildasm/Microsoft.dotnet-ildasm.proj Traversal project configuration for ildasm tool package with IsILToolPackage property
src/coreclr/.nuget/Microsoft.dotnet-ildasm/Microsoft.dotnet-ildasm.pkgproj Package project with metadata, RID-specific binary inclusion, and dynamic manifest generation for ildasm
src/coreclr/.nuget/Microsoft.dotnet-ildasm/DotnetToolSettings.xml Tool manifest for RID-specific ildasm packages defining command name and executable runner
eng/Publishing.props Adds artifact visibility configuration for the new tool packages in VMR builds

Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, but I'd prefer if we could make this work without using the .pkgproj tooling and instead use the .NET SDK NuGet targets.

Is there any way we can adjust this to use the .NET SDK targets instead?

@jcouv jcouv marked this pull request as draft December 8, 2025 07:24
@dotnet-policy-service
Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Development

Successfully merging this pull request may close these issues.

ilasm/ildasm as dotnet global tools

7 participants