dotnet build configuration Release throws MSB3474

379 views Asked by At

When executing a default (Debug) configuration I get no errors, but when I do run this:

dotnet build .\src\Burriquin\Burriquin.csproj -c=Release

I get this error:

C:\Program Files\dotnet\sdk\7.0.102\Microsoft.Common.CurrentVersion.targets(3822,5): error MSB3474: The task "SGen" is not supported on the .NET Core version of MSBuild. Use the Microsoft XML Serializer Generator package instead. See https://go.microsoft.com/fwlink/?linkid=858594 for more information. [C:\Users\mynameUser\Documents\MyProject\src\Burriquin\Burriquin.DB.csproj] 0 Warning(s) 1 Error(s)

In my csproj file I've not configured anything special for the build configuration, here the lines:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />

Some extran info: I'm able to build in those two configurations via VS-2022.

1

There are 1 answers

0
juagicre On BEST ANSWER

For .net Framework using the dotnet build toolset the non-Debug configurations should contain this tag: <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> configuration ends up being something like this:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" >
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RC|AnyCPU'" >
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>

So, if you have got an extra configuration, it should also disable the assembly serialization.

There is a thread in github that talks about it, but it's hard to follow and does not throw any lesson out of: .net framework is old stuff, so do a workaround for the dotnet build for developers not to complain too hard.