I have: a .NET Core App, modified for VS 2017 and consuming a TFS Feed.
When it was in VS 2015, NuGet restore
was working fine.
Now using VS 2017, NuGet restore
it doesn't work returning a Failed to load msbuild Toolset
... Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0
I also try to use dotnet restore
and I got a 401 (Unauthorized)
response.
Apparently NuGet restore
is the preferred way to do it, since it automatically authenticated for us, in order to use TFS Feed, but it seems to don't recognize VS 2017.
Update 3/20/2017
Sorry for the confusion, I forgot to mention that the problem is using CI/CD Visual Studio Team Services / Build. In my PC, it works fine because I had NuGet 4 (it come with VS 2017)... but online the NuGet versions available (with access to private feed) are: 3.3 and 3.5
Update 3/25/2017
After I added the nuget 4.0 to the build as @Cece-MSFT suggested, I still getting an error but without much detail. see screenshot:
I've tried with TFS 2017 + VS 2017 + Nuget 4.0.0.2323, after add the TFS feed in Package Source in VS, VS can restore it successfully.
You may compare your environment with mine, especially Nuget version, as someone has similar issue with a previous Nuget version, check: https://github.com/NuGet/Home/issues/3975
=========================================================================
Add a screenshot:
You could use the nuget global config file of your build server located in %APPDATA%\NuGet\NuGet.Config
I had a different cause, in VSTS/Azure DevOps using "Use Nuget" first then "NuGet restore" second, on Hosted agent...the restore was throwing this error.
I had to change this...
to this...
And the error went away.
Hope this helps!
I tried several of the suggestions from @Cece-MSFT but was unable to get those to work without errors. Here is what did work for me. I had to check in the 4.0.* version of nuget.exe into version control. I added a command line utility and executed my checked in nuget.exe and everything worked perfectly.
Note: This also works with a mix of .net core and asp.net framework class libraries. This was an issue reported on github.
Note2: I am using the .csproj version (VS 2017, no project.json) for all my .net core projects in my solution.
Here is a screen of my nuget restore build step. Hope this helps someone.
I've managed to fix this by making sure the following settings are used on the build:
No idea why you need this specific combination haha!
Just realised that you are building a CORE app sorry. For this the restore is fine by then the build fails expanding the packages. One step closer I suppose!
I fixed this by removing the nuget restore step and adding /t:restore on the msbuild arguments. By doing that you don't need to manually upgrade nuget.