Nicholas Nicholas - 1 year ago 323
C# Question

Unable to load Visual Studio 2015 project after adding dependency on Microsoft.Net.Compilers

My project has a dependency on the NuGet package


<package id="Microsoft.Net.Compilers" version="1.3.2"
targetFramework="net461" developmentDependency="true" />

However, if I'm loading Visual Studio after having cleared my packages folder my projects won't load with the following error:

The imported project "C:\MyService\packages\Microsoft.Net.Compilers.1.3.2\tools\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.CurrentVersion.targets

So it won't load the project because it's missing a file which is restored on build using Nuget, which only works if I can load the project.

Answer Source

You can use the Nuget commandline tool to restore your packages. If your system doesn't yet have it, you can find it here:

Issue this on the commandline:

nuget restore
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download