Skip to content

.NET 4.6.1/.NET Standard 2.0 build with SGen fails #1630

@emmanuelguerin

Description

@emmanuelguerin

The 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 #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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions