Skip to content

Cross-gen failed to produce PDB for C# Dev Kit binaries #89337

@lifengl

Description

@lifengl

Description

Cross-gen works for our binaries but stops working if we want to produce PDB files for cross-gen binaries.

This might happen due to our package has code referencing msbuild, but msbuild binaries are not included in the package. (We expect to load them from the SDK folder based on global.json of the user project, instead of using one from the developing time. It doesn't seem to be a problem in our another package.

Here are the call stacks in the build log:

If we skip building PDB, the problem will disappear.

D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): Error: Failed to load assembly 'Microsoft.Build' [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): Internal.TypeSystem.TypeSystemException+FileNotFoundException: Failed to load assembly 'Microsoft.Build' [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID, String) + 0x30 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.ResolutionFailure.Throw() + 0x117 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.Ecma.EcmaModule.GetObject(EntityHandle, NotFoundBehavior) + 0x9a [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.Ecma.EcmaModule.GetType(EntityHandle) + 0x11 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.Ecma.EcmaType.InitializeBaseType() + 0x75 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.Ecma.EcmaType.ComputeTypeFlags(TypeFlags) + 0x44 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.TypeDesc.InitializeTypeFlags(TypeFlags) + 0x17 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.TypeNameFormatter.AppendName(StringBuilder, TypeDesc) + 0x27 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.JitInterface.TypeString.AppendNameForInstantiatedType(StringBuilder, DefType) + 0x88 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.JitInterface.TypeString.AppendNameForInstantiatedType(StringBuilder, DefType) + 0x88 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at Internal.TypeSystem.TypeNameFormatter.FormatName(TypeDesc) + 0x4e [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.PEWriter.OutputInfoBuilder.FormatMethodName(MethodDesc, TypeNameFormatter) + 0x83 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.PEWriter.OutputInfoBuilder.d__16.MoveNext() + 0x162 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.Diagnostics.PdbWriter.WritePDBDataHelper(String, IEnumerable1) + 0x6f1 [D:\a\_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj] D:\a\_work\_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.Diagnostics.PdbWriter.WritePDBData(String, IEnumerable1) + 0x1b [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.DependencyAnalysis.ReadyToRunObjectWriter.EmitPortableExecutable() + 0x9ce [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.ReadyToRunCodegenCompilation.Compile(String) + 0x18d [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.Program.RunSingleCompilation(Dictionary2, InstructionSetSupport, String, Dictionary2, HashSet`1, CompilerTypeSystemContext) + 0x17b0 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.Program.Run(String[]) + 0xd6b [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]
D:\a_work_tool\dotnet\sdk\7.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(465,5): at ILCompiler.Program.Main(String[]) + 0x32 [D:\a_work\1\s\src\Microsoft.VisualStudio.ProjectSystem.Server.Package\Microsoft.VisualStudio.ProjectSystem.Server.Package.csproj]

Reproduction Steps

It failed in the project system build pipeline.

Expected behavior

be able to produce PDB.

Actual behavior

should be able to produce PDB.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions