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

I have: .NET Core App, modified for VS 2017 and using the TFS channel. When it was in VS 2015 , NuGet restore worked fine. Now, using VS 2017 , NuGet restore does not work, returning Failed to load msbuild Toolset ... Could not load file or assembly 'Microsoft.Build, Version=14.0.0.0

I am also trying to use dotnet restore and I got a 401 (Unauthorized) response.

NuGet restore seems to be the preferred way to do this, as it automatically authenticates for us to use the TFS tape, but doesn't seem to recognize VS 2017.

Update 03.20.2017

Sorry for the confusion, I forgot to mention that the problem is using CI / CD Visual Studio Team Services / Build. It works fine on my PC because I had NuGet 4 (it comes with VS 2017) ... but on the Internet, NuGet versions are available (with access to a private tape): 3.3 and 3.5

Update 03.25.2017

After I added Nuget 4.0 to the assembly, as @ Cece-MSFT suggested, I still get an error message, but without much detail. see screenshot: enter image description here

+6
source share
7 answers

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

  • Instead of using NuGet v3.3 and v3.5 ... NuGet v4.0 is now supported

enter image description here

  1. And my beloved, he should use the NuGet v1 recovery version. *, and now I have the option to select my own VSTS channel ... so I don’t need the NuGet.config file anymore.

enter image description here

+1
source

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

+1
source

I tried with TFS 2017 + VS 2017 + Nuget 4.0.0.2323, after adding the TFS feed to Source Source in VS, VS can restore it successfully.

You can compare your environment with mine, especially with the version of Nuget, since someone has a similar problem with the previous version of Nuget, check: https://github.com/NuGet/Home/issues/3975

==================================================== =========================

Add screenshot:

enter image description here

0
source

I tried some suggestions from @ Cece-MSFT, but could not get them to work without errors. Here is what I did for me. I had to check the version of nuget.exe 4.0. * In version control. I added a command line utility and executed mine checked in nuget.exe, and everything worked fine.

Note. It also works with a set of .net core and asp.net class libraries. This was an issue reported on github.

Note 2. I am using the .csproj version (VS 2017, no project.json) for all my .net projects in my solution.

Here is a screen of my nuget recovery build phase. Hope this helps someone.

enter image description here

0
source

I fixed this by removing the nuget restore step and adding / t: restore to the msbuild arguments. However, you do not need to manually update nuget.

0
source

I managed to fix this by making sure that the following settings are used in the assembly:

  • Agent hosted, but NOT Hosted VS2017
  • Nuget Recovery Task - v3.5
  • Build Task Defines VS2017

I don't know why this particular combination is needed haha!

Just realized that you are building a CORE application sorry. For this, recovery is in order, then the assembly does not allow you to deploy packages. I guess one step!

0
source

I had another reason: in VSTS / Azure DevOps, they first used "Use Nuget" and then "NuGet restore" on the hosted agent ... Restore caused this error.

I had to change this ...

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

to that...

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

And the error is gone.

Hope this helps!

0
source

Source: https://habr.com/ru/post/1265588/


All Articles