Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.XmlSerializer.Generator (sgen) fails when Microsoft.NETCore.App 2.0.x is installed #33285

Closed
oatkins opened this issue Mar 6, 2020 · 1 comment

Comments

@oatkins
Copy link

oatkins commented Mar 6, 2020

The Microsoft.XmlSerializer.Generator package should cause an XML serialization assembly to be generated on build. However, on a machine with a 2.0.x (e.g. 2.0.9) .NET core runtime installed, it fails with the following:

Method 'System.Xml.Serialization.XmlSerializer.GenerateSerializer' was not found. This is likely because you are using an older version of the framework. Please update to .NET Core v2.1 or later.
Sgen utility failed to pregenerate serialization code for d:\src\dump\Microsoft.XmlSerializer.Generator.Fail\Microsoft.XmlSerializer.Generator.Fail\obj\Debug\netstandard2.0\Microsoft.XmlSerializer.Generator.Fail.dll.
C:\Users\Oliver.nuget\packages\microsoft.xmlserializer.generator\2.2.0\build\Microsoft.XmlSerializer.Generator.targets(38,5): warning : SGEN: Failed to generate the serializer for Microsoft.XmlSerializer.Generator.Fail.dll. Please follow the instructions at https://go.microsoft.com/fwlink/?linkid=858594 and try again.

This can be reproduced easily with the following project file:

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.XmlSerializer.Generator" Version="2.2.0" />
  </ItemGroup>

</Project>

and this code:

namespace Microsoft.XmlSerializer.Generator.Fail
{
    public class Class1
    {
    }
}

It seems as though this is caused by incorrect values in https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.XmlSerializer.Generator/pkg/build/dotnet-Microsoft.XmlSerializer.Generator.runtimeconfig.json:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.0.0"
    }
  }
}

As per the error message, the required runtime is 2.1.x.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Serialization untriaged New issue has not been triaged by the area owner labels Mar 6, 2020
@HongGit HongGit removed the untriaged New issue has not been triaged by the area owner label Mar 12, 2020
@HongGit
Copy link
Contributor

HongGit commented Mar 12, 2020

Thanks for reporting this issue!.

This is a duplicate issue as #630.

@HongGit HongGit closed this as completed Mar 12, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants