TFS Build Agent failed on Nuget Restore for: .Net Core + VS 2017 + private TFS Feed

房东的猫 提交于 2019-12-23 09:01:34

问题


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:


回答1:


Finally, some upgrades and there are 2 options, how to solve this:

  1. Instead of using NuGet v3.3 and v3.5... there is now support for NuGet v4.0

  1. And my Favorite, It's to use a NuGet Restore version v1.*, and now I have the option to select my own VSTS Feed... so I don't need the NuGet.config file anymore.




回答2:


You could use the nuget global config file of your build server located in %APPDATA%\NuGet\NuGet.Config




回答3:


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:




回答4:


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.




回答5:


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.




回答6:


I've managed to fix this by making sure the following settings are used on the build:

  • Agent is hosted but NOT Hosted VS2017
  • Nuget restore task is v3.5
  • Build task specifies VS2017

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!




回答7:


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...

Path to solution, packages.config, or project.json: **/*.sln

to this...

Path to solution, packages.config, or project.json: **\{YOUR_SOLUTION_NAME}.sln

And the error went away.

Hope this helps!



来源:https://stackoverflow.com/questions/42849556/tfs-build-agent-failed-on-nuget-restore-for-net-core-vs-2017-private-tfs-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!