3

Step :1 Code: dotnet build E:\abc.csproj /p:Platform=ANYCPU /p:Configuration=Release . Error: C:\Program Files\dotnet\sdk\5.0.202\Microsoft.Common.CurrentVersion.targets(3624,5): error MSB3474: The tas k "SGen" is not supported on the .NET Core version of MSBuild. Use the Microsoft XML Serializer Generator p ackage instead. See https://go.microsoft.com/fwlink/?linkid=858594 for more information. [E:\abc.csproj]

Step:2 I had applied the below solution but didn't work. Command:dotnet add E:\abc.csproj package Microsoft.XmlSerializer.Generator -v 1.0.0

I had read a document and implement a solution but the solution has some issues. sp command: 'dotnet add E:\abc.csproj package Microsoft.XmlSerializer.Generator -v 1.0.0' Error: Determining projects to restore... Writing C:\Users\AppData\Local\Temp\tmpF1E.tmp info : Adding PackageReference for package 'Microsoft.XmlSerializer.Generator' into project 'E:\abc.csproj'. error: Error while adding package 'Microsoft.XmlSerializer.Generator' to project 'E:\abc.csproj'. The project does not support adding package references through the add package command.

https://go.microsoft.com/fwlink/?linkid=858594

  • So basically you're saying that you have encountered an exception message on some unknown to us solution.. What is your question, where is the code? – Theo Apr 19 '21 at 10:07
  • I have updated it in details. – Nirav Patel Apr 21 '21 at 05:28
  • 1
    I am getting this error on GitHub build porting a .net framework project to .net core. It looks like SGen is an Xml optimizer that is not compatible. Did you figure out the issue and how to fix it? – WillC Jul 07 '21 at 03:04
  • @Willc still I can't solve the issue, if you found any solution then please update here. It will be helpful to me. – Nirav Patel Jul 07 '21 at 14:53

1 Answers1

1

Remove this line from the csproj file:

<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
Sire
  • 4,086
  • 4
  • 39
  • 74
  • I cannot try this option because I cannot touch the csproj file in question. Is there an alternative for such cases? – alelom Jan 20 '23 at 17:53
  • 1
    Make a copy of the csproj file for .NET 6. Or if that's totally impossible, you could try to build with "dotnet msbuild" (or just "msbuild") on the specific projects before you run "dotnet build" on the solution. This works sometimes. – Sire Jan 21 '23 at 19:40