Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active March 13, 2018 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refactorsaurusrex/e98b8a1ac154e1e0ccea73c24a072fc0 to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/e98b8a1ac154e1e0ccea73c24a072fc0 to your computer and use it in GitHub Desktop.
Nuget 'update' command fails: 'Microsoft.CSharp.Core.targets' was not found

When running nuget update 'some.solution.sln' -id 'Some.Package.Id' yesterday, I got the following error:

Scanning for projects...
MSBuild auto-detection: using msbuild version '15.4.8.50001' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\
Enterprise\MSBuild\15.0\bin'.
The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\Roslyn\
Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, 
and that the file exists on disk.  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\
Microsoft.CSharp.CurrentVersion.targets

Eventually I saw that the auto-detected version of MSBuild was withinin an Enterprise Visual Studio directory. I do not have an Enterprise version of Visual Studio installed, so I tried running this command instead:

nuget update 'some.solution.sln' -id 'Some.Package.Id' -MSBuildPath 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64'

Notice that the path above has 'Professional' in it, instead of 'Enterprise'. (Also note that passing a fully qualified path to msbuild.exe won't work.) This time, the command succeeded! But since I didn't want to pass that path to nuget every time I called it, I just deleted the Enterprise copy of msbuild.exe and auto-detection just used the file contained in the 'Professional' directory instead.

@DavidKDeutsch
Copy link

THANK YOU! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment