Nuget packages aren't copied to output when using .NETStandard
Asked Answered
A

1

9

I want to share a project between a WPF (.NET 4.6) application and a .NET Core application. To do this I've made a .NET Standard library by making a portable library initially and converting it in Visual Studio 2015 to .NETStandard version 1.3.

However, the .NETStandard library needs to reference Entity Framework (for example) and so I've added this dependency in the project.json and everything builds happily. However, when I actually run the application, I get a File Not Found exception as soon as I actually try to load data using the Entity Framework library. This is expected, since none of the nuget packages when using .NETStandard are copied to the output directory (unlike using nuget for normal .NET), so I can see the reason for the exception.

How do I fix this/get the nuget dependencies to be copied to output when using a .NETStandard library and referencing from a .NET 4.6 project? (Below is my project.json and happy to add more code if needed).

{
  "supports": {},
  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.1.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "NETStandard.Library": "1.6.1"
   },
  "frameworks": {
    "netstandard1.3": {}
  }
}
Arsenault answered 27/12, 2016 at 20:6 Comment(1)
Switch to Visual Studio 2017 RC and that's the only environment on Windows to simplify the project reference scenario.Kenyettakenyon
R
5

Microsoft finally admitted this is a problem and will fix it, expectantly, in NuGet version 4.0.1, the first update to NuGet 4 after VS 2017 ships.

The cleanest workaround now is to add <RestoreProjectStyle>PackageReference</RestoreProjectStyle> to a legacy project.

However according to Rob Relyea MS will ignore this property after RTM so another workaround is <PackageReference Update="PlaceholderToConvinceThisProjectToGetTransitivePackageReferenceFromProjectReferences"/>.

Rombert answered 10/2, 2017 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.