.NET 11 preview-7: Crossgen fails when building PowerShell on Linux and macOS
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
### Description
We moved PowerShell to use the latest .NET SDK 11.0.100-preview.7 and that broke the PowerShell build on Linux and macOS. Build on Windows is fine.
Here are the CI runs
Linux -- Ubuntu 24.04: [27828/merge - 6179 · PowerShell/PowerShell@623e11d](https://github.com/PowerShell/PowerShell/actions/runs/31543405629/job/93950685455)
macOS -- 15.7.7: [27828/merge - 6136 · PowerShell/PowerShell@623e11d](https://github.com/PowerShell/PowerShell/actions/runs/31543405618/job/93950712297)
The build failure output:
```
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : Error: Failed to load assembly 'System.Formats.Nrbf' [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'System.Formats.Nrbf' [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID, String) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.cs:line 41 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.ResolutionFailure.Throw() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Common/ResolutionFailure.cs:line 105 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaModule.GetObject(EntityHandle, NotFoundBehavior) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaModule.cs:line 527 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaSignatureParser.ResolveHandle(EntityHandle) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs:line 61 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseTypeImpl(SignatureTypeCode) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs:line 256 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseMethodSignatureImpl(Boolean) in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs:line 403 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseMethodSignature() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs:line 337 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at Internal.TypeSystem.Ecma.EcmaMethod.InitializeSignature() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs:line 88 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.DependencyAnalysis.ReadyToRun.InheritedVirtualMethodsNode.GetConditionalStaticDependencies(NodeFactory) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/InheritedVirtualMethodsNode.cs:line 91 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 194 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 261 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 309 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.ReadyToRunCodegenCompilation.Compile(String) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs:line 402 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, ReadyToRunCompilerContext, Logger) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 693 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 314 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
/usr/share/dotnet/sdk/11.0.100-preview.7.26381.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.CrossGen.targets(501,5): error : at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass216_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs:line 275 [/home/runner/work/PowerShell/PowerShell/src/powershell-unix/powershell-unix.csproj]
```
### Reproduction Steps
Building PowerShell on Linux (e.g. Ubuntu 24.04) and macOS (e.g. 15.7.7).
The `_CreateR2RImages` step will take forever and eventually timed out (cancelled by `ctrl+c`) with the error output shared above.
### Expected behavior
PowerShell build successfully with the `_CreateR2RImages` step finishes within 30 seconds or so. That's the behavior before us moving to .NET 11 preview.7.
### Actual behavior
`_CreateR2RImages` takes forever and eventually fails.
### Regression?
Yes, a regression to .NET 11 preview.6 and prior versions of SDK.
### Known Workarounds
None.
### Configuration
_No response_
### Other information
_No response_
Contributor guide
Research direction
Reproduce the failure by building src/powershell-unix/powershell-unix.csproj on Ubuntu 24.04 and macOS 15.7.7, focusing on the _CreateR2RImages step and the Microsoft.NET.CrossGen.targets error for System.Formats.Nrbf. Compare the behavior with .NET 11 preview.6 or earlier; done means both builds complete successfully and the step finishes in about 30 seconds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100