I am referencing a .NET Standard 2.0.0 project in a .NET 4.6.1 project.
Building the project locally works fine. Building it with a hosted agent on VSTS gives the following error:
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'.
Adding the netstandard assembly in Web.config as described here, didnt work, same error:
<system.web> <compilation debug="true" targetFramework="4.6.1" > <assemblies> <add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/> </assemblies> </compilation> <httpRuntime targetFramework="4.6.1" />
Also tried adding the NETStandard.Library.NETFramework Nuget package. Got alot of errors like this:
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\a\1\s\packages\NETStandard.Library.NETFramework.2.0.0-preview2-25405-01\build\net461\ref\System.Xml.XmlSerializer.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\Facades\System.Xml.XmlSerializer.dll'. Remove one of the duplicate references.
Used the latest NETStandard.Library.NETFramework package on Nuget.org - 2.0.0-preview2-25405-01. The description of the package says:
This package is deprecated. To consume .NET Standard libraries from .NET Framework in VS2017 15.3, you only need the .NET Core 2.0 SDK installed. For VS 2015, you'll need NuGet client 3.6 or higher.
Also tried adding the ".NET Core Tool Installer" for v. 2.0.0 as the first build step. No luck.
Here is my current build configuration. How do I make it work for a .NET 4.6.1 project referencing a .NET Standard 2.0 library?