Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

new .net core visual studio 2017 project nuget restore in CI build definition

So currently, I am working on a .net core project in Visual Studio 2017. And I am also need to setup CI (Continuous Integration) in VSTS.

Here is my nuget restore step in my build definition

enter image description here

But my build is failing because it couldn't restore any packages. Here is the log of its. It said that "None of the projects in this solution specify any packages". I know that in VS2017 they changed the way nuget packages are being handled. Anyone has an idea or experience about this?

2017-03-22T20:25:11.9517911Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2017-03-22T20:25:11.9674167Z Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
2017-03-22T20:25:11.9830425Z ##[section]Finishing: NuGet restore **/*.sln

I don't want to use dotnet restore because Microsoft said that

.NET Core's dotnet restore command doesn't currently support encrypted credentials. To use VSTS NuGet feeds with dotnet restore, you'll need to specify a Personal Access Token in plain text.

so I don't want to store my Personal Access Token. https://www.visualstudio.com/en-us/docs/package/nuget/auth#net-core

like image 432
Hung Cao Avatar asked Mar 22 '17 20:03

Hung Cao


1 Answers

You need to use NuGet 4.0.

Download it form the official NuGet site. https://dist.nuget.org/index.html

Put it in a folder on the machine where you have the build agent.

In the Advanced settings of the NuGet restore step set the NuGet version to Custom.

In the Path to NuGet.exe specify the path where you have put the NuGet.exe file. This is the path on the machine where the build agent is running. I tried with a relative path but was not able to get it working so in the end I have put an absolute path. This might be a problem for you if you have multiple agents with different paths so you might need to figure out how to correctly specify the relative path.

like image 86
AlesD Avatar answered Sep 24 '22 15:09

AlesD