From e6f5daac2bbe06e660c7fc62c07e12e2437e05d5 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Sep 2026 10:30:59 -0700 Subject: [PATCH 1/9] Use project references for shared framework packs Derive managed shared framework and generator inputs from NetCoreAppLibrary.props, and rebuild native library inputs through build-native.proj before packaging. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- eng/Subsets.props | 9 ++- eng/liveBuilds.targets | 29 +++++++-- .../Microsoft.NETCore.App.Ref.sfxproj | 59 +++++++++++++++++-- ...rosoft.NETCore.App.Runtime.CoreCLR.sfxproj | 19 ++++-- .../Microsoft.NETCore.App.Runtime.props | 30 +++++++++- .../NetCoreAppLibraryProjectReferences.props | 47 +++++++++++++++ src/libraries/sfx-gen.proj | 13 +--- src/libraries/sfx-src.proj | 14 +---- 8 files changed, 180 insertions(+), 40 deletions(-) create mode 100644 src/libraries/NetCoreAppLibraryProjectReferences.props diff --git a/eng/Subsets.props b/eng/Subsets.props index d7b4c953cd9f73..54f84aaea37ff3 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -635,7 +635,10 @@ - + @@ -764,7 +767,9 @@ - + diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index e494ca933bdbea..0e650e92fffe8e 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -166,16 +166,25 @@ Ensure artifacts exist for the more advanced paths. If the configuration is '*', don't emit these errors: it isn't a local dev scenario. --> - + + + + + @@ -185,10 +194,8 @@ - + + + + + + + @@ -373,6 +387,11 @@ + + + + + + + + + + + + + + + + <_NetCoreAppRefPackGeneratorFile Include="@(_NetCoreAppRefPackGeneratorFileWithOriginalPath)" + RemoveMetadata="IsSymbol"> + $([System.Text.RegularExpressions.Regex]::Replace($([System.Text.RegularExpressions.Regex]::Replace($([System.String]::Copy('%(_NetCoreAppRefPackGeneratorFileWithOriginalPath.PackagePath)').Replace('\', '/')), '^analyzers/dotnet/roslyn[^/]+/', 'analyzers/dotnet/')), '/[^/]+$', '/')) + + + + + - + <_NetCoreAppLibraryPublicSourceAssembly Include="@(_NetCoreAppLibrarySourceAssembly)" + Condition="'%(_NetCoreAppLibrarySourceAssembly.Extension)' == '.dll' and '%(_NetCoreAppLibrarySourceAssembly.IsPrivateAssembly)' != 'true'" /> + <_NetCoreAppLibrarySourceAssemblyWithReferenceAssembly Include="@(_NetCoreAppLibraryPublicSourceAssembly)" + Condition="'%(_NetCoreAppLibraryPublicSourceAssembly.ReferenceAssembly)' != ''" /> + <_NetCoreAppLibraryReferenceAssembly Include="@(_NetCoreAppLibrarySourceAssemblyWithReferenceAssembly->Metadata('ReferenceAssembly'))" /> + <_NetCoreAppLibraryReferenceAssembly Include="@(_NetCoreAppLibraryPublicSourceAssembly)" + Exclude="@(_NetCoreAppLibrarySourceAssemblyWithReferenceAssembly)" /> + <_NetCoreAppLibraryReferenceAssemblySymbols Include="@(_NetCoreAppLibraryReferenceAssembly->'%(RootDir)%(Directory)%(Filename).pdb')" /> + <_NetCoreAppLibraryReferenceAssemblySymbols Remove="@(_NetCoreAppLibraryReferenceAssemblySymbols)" + Condition="!Exists('%(_NetCoreAppLibraryReferenceAssemblySymbols.Identity)')" /> + - - - + <_NetCoreAppLibrarySourceAssemblyWithDocumentation Include="@(_NetCoreAppLibraryPublicSourceAssembly)" + Condition="'%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)' != '' and Exists('%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)')" /> + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index 55cfb97672da4e..ccfe3b6c5dfaf2 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -73,14 +73,16 @@ true <_WasmFrameworkR2RDir>$([MSBuild]::NormalizeDirectory('$(IntermediateOutputPath)', 'framework-r2r')) + <_WasmFrameworkR2RResponseFile>$(_WasmFrameworkR2RDir)references.rsp + DependsOnTargets="ResolveProjectReferences;ResolveRuntimeFilesFromLocalBuild"> - <_WasmFrameworkR2RInput Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll" - Exclude="$(LibrariesSharedFrameworkBinArtifactsPath)*.resources.dll" /> + <_WasmFrameworkR2RInput Include="@(_NetCoreAppLibrarySourceAssembly)" + Condition="'%(_NetCoreAppLibrarySourceAssembly.Extension)' == '.dll' and '%(_NetCoreAppLibrarySourceAssembly.Filename)' != 'System.Private.CoreLib'" /> + <_WasmFrameworkR2RReference Include="@(_WasmFrameworkR2RInput)" /> <_WasmFrameworkR2RInput Remove="@(_WasmFrameworkR2RInput)" Condition="'$(WasmFrameworkR2RSubset)' != '' and !$([System.String]::Copy(';$(WasmFrameworkR2RSubset);').Contains(';%(FileName);'))" /> @@ -89,7 +91,7 @@ - <_WasmFrameworkR2RReference Include="$(LibrariesSharedFrameworkBinArtifactsPath)*.dll" /> + <_WasmFrameworkR2RReferenceArgument Include="@(_WasmFrameworkR2RReference->'-r:"%(Identity)"')" /> <_WasmCoreLibIL Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.dll')">$(CoreCLRArtifactsPath)System.Private.CoreLib.dll @@ -104,6 +106,10 @@ Inputs="@(_WasmFrameworkR2RInput);@(_WasmFrameworkR2RReference);$(_WasmCoreLibIL);$(_WasmCrossgen2Exe)" Outputs="@(_WasmFrameworkR2RInput->'%(OutputWasm)')"> + - + + + + + + - - - - - + diff --git a/src/libraries/sfx-src.proj b/src/libraries/sfx-src.proj index 8da1f3b306c227..b2823831c9be8d 100644 --- a/src/libraries/sfx-src.proj +++ b/src/libraries/sfx-src.proj @@ -7,18 +7,10 @@ true - + + - - - + From de94a3345437328e124ca8b8bfed4339fff4a8c3 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Sep 2026 13:53:02 -0700 Subject: [PATCH 2/9] Limit ref pack generators to netstandard2.0 Avoid building every target framework for generator project references while preserving the existing ref pack analyzer layout. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- .../Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj index 08d669fb6f476b..7b5f2004d4ff7f 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj @@ -22,14 +22,15 @@ + SetConfiguration="Configuration=$(LibrariesConfiguration)" + SetTargetFramework="TargetFramework=netstandard2.0" /> From 3689d42567d348d20ecd652eb01f11609550cb8d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 2 Sep 2026 15:49:33 -0700 Subject: [PATCH 3/9] Package ref generators from project outputs Use the generator project references to collect analyzer files and preserve no-build and Visual Studio packing from existing outputs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- .../Microsoft.NETCore.App.Ref.sfxproj | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj index 7b5f2004d4ff7f..3b820e4beae08d 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj @@ -21,31 +21,37 @@ OutputItemType="_NetCoreAppLibrarySourceAssembly" /> + SetTargetFramework="TargetFramework=netstandard2.0" + Targets="Build;GetAnalyzerPackFiles" /> - - - - + + + + <_NetCoreAppRefPackGeneratorOutput Include="@(_NetCoreAppRefPackGeneratorFile)" /> + - - <_NetCoreAppRefPackGeneratorFile Include="@(_NetCoreAppRefPackGeneratorFileWithOriginalPath)" - RemoveMetadata="IsSymbol"> - $([System.Text.RegularExpressions.Regex]::Replace($([System.Text.RegularExpressions.Regex]::Replace($([System.String]::Copy('%(_NetCoreAppRefPackGeneratorFileWithOriginalPath.PackagePath)').Replace('\', '/')), '^analyzers/dotnet/roslyn[^/]+/', 'analyzers/dotnet/')), '/[^/]+$', '/')) - + + + + + <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorOutput)" /> + <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorOutput->'%(RootDir)%(Directory)%(Filename).pdb')" /> + <_NetCoreAppRefPackGeneratorRelatedFile Include="%(_NetCoreAppRefPackGeneratorOutput.RootDir)%(_NetCoreAppRefPackGeneratorOutput.Directory)*\%(_NetCoreAppRefPackGeneratorOutput.Filename).resources.dll" /> + <_NetCoreAppRefPackGeneratorRelatedFile Remove="@(_NetCoreAppRefPackGeneratorRelatedFile)" + Condition="!Exists('%(_NetCoreAppRefPackGeneratorRelatedFile.Identity)')" /> - - <_NetCoreAppLibraryPublicSourceAssembly Include="@(_NetCoreAppLibrarySourceAssembly)" Condition="'%(_NetCoreAppLibrarySourceAssembly.Extension)' == '.dll' and '%(_NetCoreAppLibrarySourceAssembly.IsPrivateAssembly)' != 'true'" /> @@ -64,8 +70,12 @@ Condition="'%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)' != '' and Exists('%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)')" /> + + TargetPath="analyzers/dotnet/cs/%(_NetCoreAppRefPackGeneratorRelatedFile.RecursiveDir)" /> From 53d9de87370261636d5d7dbe95a77f157da30fae Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 3 Sep 2026 10:53:43 -0700 Subject: [PATCH 4/9] Use generator target paths for ref pack Derive generator assemblies, symbols, and resources uniformly from project reference target paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- .../Microsoft.NETCore.App.Ref.sfxproj | 31 +++---------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj index 3b820e4beae08d..75bb3c07743fc6 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj @@ -24,35 +24,18 @@ OutputItemType="_NetCoreAppRefPackGeneratorFile" ReferenceOutputAssembly="false" SetConfiguration="Configuration=$(LibrariesConfiguration)" - SetTargetFramework="TargetFramework=netstandard2.0" - Targets="Build;GetAnalyzerPackFiles" /> + SetTargetFramework="TargetFramework=netstandard2.0" /> - - - <_NetCoreAppRefPackGeneratorOutput Include="@(_NetCoreAppRefPackGeneratorFile)" /> - - - - - - - <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorOutput)" /> - <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorOutput->'%(RootDir)%(Directory)%(Filename).pdb')" /> - <_NetCoreAppRefPackGeneratorRelatedFile Include="%(_NetCoreAppRefPackGeneratorOutput.RootDir)%(_NetCoreAppRefPackGeneratorOutput.Directory)*\%(_NetCoreAppRefPackGeneratorOutput.Filename).resources.dll" /> + + <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorFile)" /> + <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorFile->'%(RootDir)%(Directory)%(Filename).pdb')" /> + <_NetCoreAppRefPackGeneratorRelatedFile Include="%(_NetCoreAppRefPackGeneratorFile.RootDir)%(_NetCoreAppRefPackGeneratorFile.Directory)*\%(_NetCoreAppRefPackGeneratorFile.Filename).resources.dll" /> <_NetCoreAppRefPackGeneratorRelatedFile Remove="@(_NetCoreAppRefPackGeneratorRelatedFile)" Condition="!Exists('%(_NetCoreAppRefPackGeneratorRelatedFile.Identity)')" /> - - - <_NetCoreAppLibraryPublicSourceAssembly Include="@(_NetCoreAppLibrarySourceAssembly)" Condition="'%(_NetCoreAppLibrarySourceAssembly.Extension)' == '.dll' and '%(_NetCoreAppLibrarySourceAssembly.IsPrivateAssembly)' != 'true'" /> <_NetCoreAppLibrarySourceAssemblyWithReferenceAssembly Include="@(_NetCoreAppLibraryPublicSourceAssembly)" @@ -69,10 +52,6 @@ <_NetCoreAppLibrarySourceAssemblyWithDocumentation Include="@(_NetCoreAppLibraryPublicSourceAssembly)" Condition="'%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)' != '' and Exists('%(_NetCoreAppLibraryPublicSourceAssembly.DocFileItem)')" /> - From 328e370e920bc2b2401995ef71e4f007e2bd20b7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 3 Sep 2026 12:03:49 -0700 Subject: [PATCH 5/9] Use managed library resolution for managed consumers Avoid requiring libs.native artifacts for NativeAOT tracing references and WebAssembly P/Invoke table generation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- src/mono/browser/browser.proj | 2 +- src/mono/wasi/wasi.proj | 2 +- src/tests/tracing/eventcounter/runtimecounters.csproj | 2 +- src/tests/tracing/eventpipe/Directory.Build.targets | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mono/browser/browser.proj b/src/mono/browser/browser.proj index 710a36801a553b..b98e470596a40e 100644 --- a/src/mono/browser/browser.proj +++ b/src/mono/browser/browser.proj @@ -39,7 +39,7 @@ - + $(WasmObjDir)\pinvoke-table.h $(WasmObjDir)\wasm_m2n_invoke.g.h diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 66fcd6e7fe4b71..c8408670ee032b 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -17,7 +17,7 @@ - + $(WasiObjDir)\pinvoke-table.h $(WasiObjDir)\wasm_m2n_invoke.g.h diff --git a/src/tests/tracing/eventcounter/runtimecounters.csproj b/src/tests/tracing/eventcounter/runtimecounters.csproj index 65765cf833dc31..11514bf23b6325 100644 --- a/src/tests/tracing/eventcounter/runtimecounters.csproj +++ b/src/tests/tracing/eventcounter/runtimecounters.csproj @@ -19,7 +19,7 @@ --> diff --git a/src/tests/tracing/eventpipe/Directory.Build.targets b/src/tests/tracing/eventpipe/Directory.Build.targets index fd50f939a9c55e..6f9eb6518aeba0 100644 --- a/src/tests/tracing/eventpipe/Directory.Build.targets +++ b/src/tests/tracing/eventpipe/Directory.Build.targets @@ -7,7 +7,7 @@ --> From 74406f120866d9e2c751129d51aed39eded1b63b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 8 Sep 2026 18:18:37 -0700 Subject: [PATCH 6/9] Reference runtime managed pack inputs by project Build CoreLib and NativeAOT managed assemblies through project references, extract MIBc merging into a dedicated producer, and let shared framework R2R process CoreLib consistently. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- eng/codeOptimization.targets | 22 +++++- eng/liveBuilds.targets | 51 ++++++------ src/coreclr/crossgen-corelib.proj | 70 +++------------- src/coreclr/merge-mibc.proj | 79 +++++++++++++++++++ src/coreclr/merge-mibc.targets | 6 ++ ...rosoft.NETCore.App.Runtime.CoreCLR.sfxproj | 46 ++++++++--- ...Microsoft.NETCore.App.Runtime.Mono.sfxproj | 21 +++++ ...soft.NETCore.App.Runtime.NativeAOT.sfxproj | 48 ++++++++++- .../Microsoft.NETCore.App.Runtime.props | 22 ++++-- src/libraries/Directory.Build.targets | 5 ++ src/libraries/sfx-src.proj | 2 + 11 files changed, 264 insertions(+), 108 deletions(-) create mode 100644 src/coreclr/merge-mibc.proj create mode 100644 src/coreclr/merge-mibc.targets diff --git a/eng/codeOptimization.targets b/eng/codeOptimization.targets index 5f990a983476d7..f642bb21ceba0e 100644 --- a/eng/codeOptimization.targets +++ b/eng/codeOptimization.targets @@ -12,6 +12,24 @@ false + + <_MibcConfiguration Condition="'$(CoreCLRConfiguration)' == ''">$(Configuration) + <_MibcConfiguration Condition="'$(CoreCLRConfiguration)' != ''">$(CoreCLRConfiguration) + true + + + + + + @@ -27,13 +45,13 @@ - + true - + diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 0e650e92fffe8e..e1b4bef9511ade 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -1,19 +1,7 @@ - + - $([MSBuild]::NormalizeDirectory('$(CoreCLROverridePath)')) - $([MSBuild]::NormalizeDirectory('$(MonoOverridePath)')) - $([MSBuild]::NormalizeDirectory('$(LibrariesOverridePath)')) - $([MSBuild]::NormalizeDirectory('$(LibrariesAllConfigurationsOverridePath)')) - - - $([MSBuild]::NormalizeDirectory('$(RuntimeArtifactsPath)')) - $([MSBuild]::NormalizeDirectory('$(RuntimeArtifactsPath)')) $(TargetOS)-$(LibrariesConfiguration)-$(TargetArchitecture) - - - - $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'coreclr', '$(TargetOS).$(TargetArchitecture).$(CoreCLRConfiguration)')) $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts', 'bin', 'mono', '$(TargetOS).$(TargetArchitecture).$(MonoConfiguration)')) $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts')) @@ -101,7 +89,12 @@ - <_nativeAotRuntimeFiles Include="$(CoreCLRAotSdkDir)*" /> + <_nativeAotProjectOutputFile Include="@(_RuntimeCoreLibFile);@(_NativeAotRuntimeAssembly)" /> + <_nativeAotRuntimeAssemblyFiles Include="@(_nativeAotProjectOutputFile->'$(CoreCLRAotSdkDir)%(Filename)%(Extension)'); + @(_nativeAotProjectOutputFile->'$(CoreCLRAotSdkDir)%(Filename).pdb')" + Condition="'$(UseRuntimeManagedProjectReferences)' == 'true'" /> + <_nativeAotRuntimeFiles Include="$(CoreCLRAotSdkDir)*" + Exclude="@(_nativeAotRuntimeAssemblyFiles)" /> true @@ -114,20 +107,25 @@ true - <_systemPrivateCoreLib Include="$(CoreCLRArtifactsPath)System.Private.CoreLib.dll" - Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.dll')" /> - <_systemPrivateCoreLib Include="$(CoreCLRArtifactsPath)IL/System.Private.CoreLib.dll" - Condition="Exists('$(CoreCLRArtifactsPath)IL/System.Private.CoreLib.dll') and '@(_systemPrivateCoreLib)' == ''" /> - - - + <_systemPrivateCoreLib Include="$(CoreCLRArtifactsPath)System.Private.CoreLib.dll" + Condition="'$(UseRuntimeManagedProjectReferences)' != 'true' and + Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.dll')" /> + <_systemPrivateCoreLib Include="$(CoreCLRArtifactsPath)IL/System.Private.CoreLib.dll" + Condition="'$(UseRuntimeManagedProjectReferences)' != 'true' and + Exists('$(CoreCLRArtifactsPath)IL/System.Private.CoreLib.dll') and + '@(_systemPrivateCoreLib)' == ''" /> + + + - + <_monoRuntimeManagedProjectFiles Include="$(MonoArtifactsPath)\System.Private.CoreLib.dll; + $(MonoArtifactsPath)\System.Private.CoreLib.pdb" + Condition="'$(UseRuntimeManagedProjectReferences)' == 'true'" /> + true diff --git a/src/coreclr/crossgen-corelib.proj b/src/coreclr/crossgen-corelib.proj index ebe09a78aa9dad..384a5cfe7a15f0 100644 --- a/src/coreclr/crossgen-corelib.proj +++ b/src/coreclr/crossgen-corelib.proj @@ -2,7 +2,13 @@ - + @@ -12,8 +18,6 @@ $([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'log')) $([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'bin', 'coreclr', $(OSPlatformConfig))) $([MSBuild]::NormalizeDirectory('$(RootBinDir)', 'obj', 'coreclr', $(OSPlatformConfig))) - $([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.sh')) - $([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.cmd')) @@ -30,8 +34,6 @@ false true - - <_MergeMibcFilesCacheFile>$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/merge_mibc_files.cache @@ -49,10 +51,6 @@ $(CrossgenTargetName);CopyR2RComponentCoreLib - - - - System.Private.CoreLib $([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).dll')) @@ -62,7 +60,6 @@ $([MSBuild]::NormalizePath('$(BinDir)', 'PDB', '$(CoreLibAssemblyName).ni.pdb')) $([MSBuild]::NormalizePath('$(BinDir)', '$(CoreLibAssemblyName).ni.r2rmap')) - $([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc')) @@ -79,55 +76,10 @@ $([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(CoreLibAssemblyName).dll')) - - - - <_MergeMibcFilesInputCache Include="@(OptimizationMibcFiles)" /> - <_MergeMibcFilesInputCache Include="@(DotNetPgo)" /> - <_MergeMibcFilesInputCache Include="@(OptimizationMibcFiles->'%(ModifiedTime)')" /> - - - - - - - - - - - - - - - - - $(DotNetCli) @(DotNetPgo) merge - $(DotNetPgoCmd) -o:$(MergedMibcPath) - $(DotNetPgoCmd) @(OptimizationMibcFiles->'-i:%(Identity)', ' ') - $(DotNetPgoCmd) --compressed false - - - - - - - - - + - + @@ -140,7 +92,7 @@ @@ -162,7 +114,7 @@ $(CrossGenDllCmd) --composite $(CrossGenDllCmd) --targetos:$(TargetOS) $(CrossGenDllCmd) --target-allows-runtime-code-generation:$(FeatureDynamicCodeCompiled) - $(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data + $(CrossGenDllCmd) -m:@(MergedMibcFile) --embed-pgo-data $(CrossGenDllCmd) -O $(CrossGenDllCmd) --verify-type-and-field-layout diff --git a/src/coreclr/merge-mibc.proj b/src/coreclr/merge-mibc.proj new file mode 100644 index 00000000000000..0ccd19135294e1 --- /dev/null +++ b/src/coreclr/merge-mibc.proj @@ -0,0 +1,79 @@ + + + + + + + + $(MSBuildThisFileDirectory)merge-mibc.targets + $(TargetOS).$(TargetArchitecture).$(Configuration) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'coreclr', '$(OSPlatformConfig)')) + $([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.sh')) + $([MSBuild]::NormalizePath('$(RepoRoot)', 'dotnet.cmd')) + $([MSBuild]::NormalizePath('$(BinDir)', 'StandardOptimizationData.mibc')) + <_MergeMibcFilesCacheFile>$(MibcOptimizationDataDir)/$(TargetOS)/$(TargetArchitecture)/merge_mibc_files.cache + + + + + + + + + + + <_MergeMibcFilesInputCache Include="@(OptimizationMibcFile)" /> + <_MergeMibcFilesInputCache Include="@(DotNetPgo)" /> + <_MergeMibcFilesInputCache Include="@(OptimizationMibcFile->'%(ModifiedTime)')" /> + + + + + + + + + + + + + + + + $(DotNetCli) @(DotNetPgo) merge + $(DotNetPgoCmd) -o:@(MergedMibcFile) + $(DotNetPgoCmd) @(OptimizationMibcFile->'-i:%(Identity)', ' ') + $(DotNetPgoCmd) --compressed false + + + + + + + + + + + + + + + + diff --git a/src/coreclr/merge-mibc.targets b/src/coreclr/merge-mibc.targets new file mode 100644 index 00000000000000..dbfeb66422a4de --- /dev/null +++ b/src/coreclr/merge-mibc.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index 1cbc5c78a0649f..5a59bdc91218ae 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -31,6 +31,7 @@ true true $(PublishReadyToRun) + <_PublishReadyToRunCrossgen2ExtraArgs Condition="'$(FeatureDynamicCodeCompiled)' != ''">$(_PublishReadyToRunCrossgen2ExtraArgs);--target-allows-runtime-code-generation:$(FeatureDynamicCodeCompiled) @@ -38,7 +39,7 @@ false wasm false - <_PublishReadyToRunCrossgen2ExtraArgs>--opt-cross-module:*;--codegenopt:JitWasmNyiToR2RUnsupported=1;--codegenopt:JitWasmSimdNyiToR2RUnsupported=1 + <_PublishReadyToRunCrossgen2ExtraArgs>$(_PublishReadyToRunCrossgen2ExtraArgs);--opt-cross-module:*;--codegenopt:JitWasmNyiToR2RUnsupported=1;--codegenopt:JitWasmSimdNyiToR2RUnsupported=1 @@ -47,6 +48,31 @@ macho + + $(CoreCLRConfiguration) + CoreCLR + true + true + + + + + + + + + + + + + + + + + @@ -87,19 +113,16 @@ <_WasmFrameworkR2RExclude Include="@(_WasmFrameworkR2RReference)" Exclude="@(_WasmFrameworkR2RInput)" /> - - <_WasmCoreLibIL Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.dll')">$(CoreCLRArtifactsPath)System.Private.CoreLib.dll - <_WasmCoreLibIL Condition="'$(_WasmCoreLibIL)' == '' and Exists('$(CoreCLRArtifactsPath)IL\System.Private.CoreLib.dll')">$(CoreCLRArtifactsPath)IL\System.Private.CoreLib.dll <_WasmCrossgen2Exe>$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(ExeSuffix)')) - + - <_ReadyToRunCompilerInputs Include="@(_WasmFrameworkR2RReference);$(_WasmCoreLibIL)" /> + <_ReadyToRunCompilerInputs Include="@(_WasmFrameworkR2RReference);@(_RuntimeCoreLibFile)" /> <_ReadyToRunCompilerInputs Include="$(Crossgen2InBuildDir)*jit*.dll;$(Crossgen2InBuildDir)*jit*.dylib;$(Crossgen2InBuildDir)*jit*.so" /> @@ -111,8 +134,6 @@ <_WasmFrameworkR2RCompileInput Include="@(_ReadyToRunCompileList)" Condition="$([System.String]::Copy('%(OutputR2RImage)').EndsWith('.wasm'))" /> <_WasmFrameworkR2ROutput Include="@(_WasmFrameworkR2RCompileInput->'%(OutputR2RImage)')" /> - <_WasmFrameworkR2ROutput Include="$(CoreCLRArtifactsPath)System.Private.CoreLib.wasm" - Condition="Exists('$(CoreCLRArtifactsPath)System.Private.CoreLib.wasm')" /> + AfterTargets="GetFilesToPackage" + DependsOnTargets="ResolveRuntimeMibcFile"> - + tools diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj index f074aa4c2e5e06..638a82e747177f 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj @@ -44,6 +44,27 @@ $(SharedFrameworkName).Runtime.$(RuntimeSpecificFrameworkSuffix).$(RuntimeIdentifier) + + $(MonoConfiguration) + Mono + true + + + + + + + + <_RuntimeCoreLibSymbol Include="@(_RuntimeCoreLibFile->'%(RootDir)%(Directory)%(Filename).pdb')" /> + <_RuntimeCoreLibSymbol Remove="@(_RuntimeCoreLibSymbol)" + Condition="!Exists('%(_RuntimeCoreLibSymbol.Identity)')" /> + + + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.NativeAOT.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.NativeAOT.sfxproj index 34587e9fa80607..738c684a9169e3 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.NativeAOT.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.NativeAOT.sfxproj @@ -1,4 +1,4 @@ - + CoreCLR true @@ -18,12 +18,54 @@ true + + $(CoreCLRConfiguration) + $([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'nativeaot', 'System.Private.CoreLib', 'src', 'System.Private.CoreLib.csproj')) + CoreCLR + true + true + + - + + + + <_NativeAotRuntimeManagedAssembly Include="@(_RuntimeCoreLibFile);@(_NativeAotRuntimeAssembly)" /> + <_NativeAotRuntimeAssemblySymbol Include="@(_NativeAotRuntimeManagedAssembly->'%(RootDir)%(Directory)%(Filename).pdb')" /> + <_NativeAotRuntimeAssemblySymbol Remove="@(_NativeAotRuntimeAssemblySymbol)" + Condition="!Exists('%(_NativeAotRuntimeAssemblySymbol.Identity)')" /> + + + + + + + + + + + + + + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props index 2449e70a676069..19d04378ad42fe 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props @@ -1,20 +1,25 @@ - - + + SkipGetTargetFrameworkProperties="true" /> @@ -52,7 +57,8 @@ <_SymbolFilesToPackage Include="@(_HostSymbolFiles->Exists())" IsNative="true" /> - + runtimes/$(RuntimeIdentifier)/native diff --git a/src/libraries/Directory.Build.targets b/src/libraries/Directory.Build.targets index dbe74e9c4c4330..b2de65daf1ac30 100644 --- a/src/libraries/Directory.Build.targets +++ b/src/libraries/Directory.Build.targets @@ -16,6 +16,11 @@ + + + + $([MSBuild]::NormalizeDirectory('$(NuGetPackageRoot)', 'netstandard.library.ref', '$(NETStandardLibraryRefVersion)', 'ref', 'netstandard2.1')) diff --git a/src/libraries/sfx-src.proj b/src/libraries/sfx-src.proj index b2823831c9be8d..606a311cb54fd0 100644 --- a/src/libraries/sfx-src.proj +++ b/src/libraries/sfx-src.proj @@ -11,6 +11,8 @@ + From 397d037b63bb3a690f567fa655f4b58a0f01d4ee Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 8 Sep 2026 21:03:39 -0700 Subject: [PATCH 7/9] Preserve analyzer resource directories Use a recursive generator resource glob and remove empty runtime pack item groups. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- .../Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj | 2 +- .../Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj | 3 --- .../Microsoft.NETCore.App.Runtime.Mono.sfxproj | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj index 75bb3c07743fc6..25bd2ce691e0d9 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Ref.sfxproj @@ -33,7 +33,7 @@ <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorFile)" /> <_NetCoreAppRefPackGeneratorRelatedFile Include="@(_NetCoreAppRefPackGeneratorFile->'%(RootDir)%(Directory)%(Filename).pdb')" /> - <_NetCoreAppRefPackGeneratorRelatedFile Include="%(_NetCoreAppRefPackGeneratorFile.RootDir)%(_NetCoreAppRefPackGeneratorFile.Directory)*\%(_NetCoreAppRefPackGeneratorFile.Filename).resources.dll" /> + <_NetCoreAppRefPackGeneratorRelatedFile Include="%(_NetCoreAppRefPackGeneratorFile.RootDir)%(_NetCoreAppRefPackGeneratorFile.Directory)**\%(_NetCoreAppRefPackGeneratorFile.Filename).resources.dll" /> <_NetCoreAppRefPackGeneratorRelatedFile Remove="@(_NetCoreAppRefPackGeneratorRelatedFile)" Condition="!Exists('%(_NetCoreAppRefPackGeneratorRelatedFile.Identity)')" /> <_NetCoreAppLibraryPublicSourceAssembly Include="@(_NetCoreAppLibrarySourceAssembly)" diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index 5a59bdc91218ae..3c83c187d1ca50 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -55,9 +55,6 @@ true - - - diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj index 638a82e747177f..e8ec67e316f6df 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.Mono.sfxproj @@ -50,9 +50,6 @@ true - - - From ef67f50d05703ba636bf542bec988c5fc5c0d70d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 14 Sep 2026 11:06:20 -0700 Subject: [PATCH 8/9] Use shared MIBc project reference condition Let all runtime packs rely on the condition in codeOptimization.targets instead of forcing the project reference locally. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- .../Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj | 1 - .../Microsoft.NETCore.App.Runtime.NativeAOT.sfxproj | 1 - 2 files changed, 2 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index 3c83c187d1ca50..7986ee45ca5717 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -52,7 +52,6 @@ $(CoreCLRConfiguration) CoreCLR true - true $([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'nativeaot', 'System.Private.CoreLib', 'src', 'System.Private.CoreLib.csproj')) CoreCLR true - true From e50c9cde708495ef6370fce66f82defe63e3dc2d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 17 Sep 2026 11:11:51 -0700 Subject: [PATCH 9/9] Fix runtime pack CoreLib and MIBc inputs Treat project-produced CoreLib as a native runtime-pack asset on every platform and include the merged MIBc project output in regular NativeAOT packs while keeping source-build excluded. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a02d8ce4-72ef-40df-b3d2-8bea5d31d7a4 --- eng/codeOptimization.targets | 4 ++-- .../Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/eng/codeOptimization.targets b/eng/codeOptimization.targets index f642bb21ceba0e..6eb04f19074f59 100644 --- a/eng/codeOptimization.targets +++ b/eng/codeOptimization.targets @@ -16,8 +16,8 @@ <_MibcConfiguration Condition="'$(CoreCLRConfiguration)' == ''">$(Configuration) <_MibcConfiguration Condition="'$(CoreCLRConfiguration)' != ''">$(CoreCLRConfiguration) true + '$(DotNetBuildSourceOnly)' != 'true' and + ('$(PublishReadyToRun)' == 'true' or '$(BuildNativeAOTRuntimePack)' == 'true')">true diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj index 7986ee45ca5717..902b99a99d6d2b 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.CoreCLR.sfxproj @@ -58,7 +58,8 @@ BeforeTargets="AddRuntimeFilesToPackage" DependsOnTargets="ResolveProjectReferences"> - +