.NET 4.6.1/.NET Standard 2.0 build with SGen fails
See original GitHub issueThe context is a .NET Standard 2.0 targeted library Lib. It is referenced by a .NET Framework 4.6.1 targeted library LibNetFramework. (see GitHub repository: https://github.com/emmanuelguerin/issue-sgen)
In LibNetFramework, serialization assemblies generation is forced by the use of the GenerateSerializationAssemblies
property set to On
. Typically, this would happen when adding a WebReference to the project.
The compilation fails with the message
SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\netfx.force.conflicts.dll.
The issue might have been corrected by the use of the patch in https://github.com/dotnet/sdk/pull/1582, that is put ine the LibNetFrameworkPatched project in the GitHub repo.
But this breaks the build, as the netstandard.dll reference is no longer added to the compilation:
LibNetFrameworkPatched\Class1.cs(9,30,9,34): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
You can find an appveyor build failing on the VS2017, and VS2017 preview: https://ci.appveyor.com/project/emmanuelguerin/issue-sgen/build/1.0.6
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:45 (9 by maintainers)
Top GitHub Comments
I I got this error only in project having web service refrences @tomek14 to fix it i disabled GenerateSerializationAssemblies on teh csproj i added this line for all the build config
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
I believe we do know now what is happening here. In order for SGen to work correctly on 4.7.1, it will require one of two possible solutions:
</Project>
tag.