You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NuGet product used: VS UI
NuGet version: NuGet Package Manager 4.1.0 (integrated in VS 15.1)
dotnet.exe --version: doesn't apply
VS version: 15.1 (26403.3)
OS version: Windows 10 1607 (14393.1198)
Worked before? If so, with which NuGet version: Works in same version with old-style csproj format
Detailed repro steps so we can see the same problem
Using Visual Studio 2017, add a reference to the NuGet package "Microsoft.CodeAnalysis.Workspaces.Common", version "2.2.0". Visual Studio will not add any binding redirects. Running "Add-BindingRedirect ClassLibrary1" from the package manager console does nothing (no error output, but also no binding redirects).
Add a file called Test1.cs:
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Host.Mef;
using NUnit.Framework;
namespace ClassLibrary1
{
[TestFixture]
public class Test1
{
[Test]
public void Test ()
{
Console.WriteLine("Hello World!");
var x = new AdhocWorkspace(MefHostServices.DefaultHost, "something");
Console.WriteLine(x.Kind);
}
}
}
Running this test throws:
System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
----> System.IO.FileLoadException : Could not load file or assembly 'System.Collections.Immutable, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Manually adding an app.config with the binding redirects that NuGet generates for an old-style csproj fixes the problem:
The reason is that binding redirects are generated automatically during build for all "executable" projects. But since a full framework test project is a library, no binding redirects are generated. The Microsoft.NET.Test.Sdk >= 15.3.* set the right properties to enable generation of binding redirects.
@dasMulli You're right, thanks - referencing the Microsoft.NET.Test.Sdk 15.3.0-preview-20170601-03 NuGet package made the problem go away. I also found https://stackoverflow.com/a/42806831/62838, which provides a different workaround (manually adding the corresponding build properties).
Details about Problem
NuGet product used: VS UI
NuGet version: NuGet Package Manager 4.1.0 (integrated in VS 15.1)
dotnet.exe --version: doesn't apply
VS version: 15.1 (26403.3)
OS version: Windows 10 1607 (14393.1198)
Worked before? If so, with which NuGet version: Works in same version with old-style csproj format
Detailed repro steps so we can see the same problem
Using Visual Studio 2017, add a reference to the NuGet package "Microsoft.CodeAnalysis.Workspaces.Common", version "2.2.0". Visual Studio will not add any binding redirects. Running "Add-BindingRedirect ClassLibrary1" from the package manager console does nothing (no error output, but also no binding redirects).
Add a file called Test1.cs:
The text was updated successfully, but these errors were encountered: