Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Microsoft.XmlSerializer.Generator broken on .NET 10.0 RC #120734

@MarkpageBxl

Description

@MarkpageBxl

Description

Using Microsoft.XmlSerializer.Generator as documented on https://learn.microsoft.com/en-us/dotnet/core/additional-tools/xml-serializer-generator does not work on .NET 10.0 RC due to a System.Runtime assembly loading issue. Attempting to use the serializer generator as documented causes the following output during build:

  sgen succeeded with 3 warning(s) (0,8s) → bin\Debug\net10.0\sgen.dll
    SGEN : warning SGEN1: Could not load file or assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0-rc.1.25451.107\ref\net10.0\System.Runtime.dll'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
    SGEN : warning SGEN1: Could not load file or assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0-rc.1.25451.107\ref\net10.0\System.Runtime.dll'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
    C:\Users\Markus\.nuget\packages\microsoft.xmlserializer.generator\10.0.0-rc.1.25451.107\build\Microsoft.XmlSerializer.Generator.targets(52,5): warning SGEN: Failed to generate the serializer for sgen.dll. Please follow the instructions at https://go.microsoft.com/fwlink/?linkid=858594 and try again.

We depend on the XML serializer generator in our products, so this is a blocking issue for us in order to release a .NET 10.0 version of our products.

Note that these errors are emitted when using Microsoft.XmlSerializer.Generator package and tool version 10.0.0-rc.1.25451.107.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.XmlSerializer.Generator" Version="10.0.0-rc.1.25451.107" />
    <DotNetCliToolReference Include="Microsoft.XmlSerializer.Generator" Version="10.0.0-rc.1.25451.107" />
  </ItemGroup>

</Project>

Reproduction Steps

Follow the minimal example shown at https://learn.microsoft.com/en-us/dotnet/core/additional-tools/xml-serializer-generator using .NET 10.0 RC.

Expected behavior

The serializer should be generated.

Actual behavior

The serializer fails to be generated because of a System.Runtime assembly loading problem.

Regression?

This worked on .NET 6.0 and .NET 8.0.

Known Workarounds

Disabling the use of the serializer generator, but this causes an unacceptable performance hit in our product.

Configuration

.NET 10.0.0-rc.1.25451.107
Windows 11 24H2 (OS build 26100.6584)
x64

Same problem occurs on Linux.

Other information

Issue previously reported on https://developercommunity.visualstudio.com/t/MicrosoftXmlSerializerGenerator-broken/10980787 ; was told to report it here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions