4
votes

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

2
What is your question?Shaun Luttin
My build is failing. My question is how shoul I setup the nuget restore step correctly to fix my buildHung Cao
I could never get 4.0 to work w/ VS 2017. Here is an answer I gave that solved the problem. It still requires checking in the 4.0.* version but works perfectly.trevorc
nuget 4x version works for me. I also needed to check it in to work around it. I am expecting Microsoft to support it betterHung Cao
The source code of Nuget installer step/task has been updated (github.com/Microsoft/vsts-tasks/tree/master/Tasks/…), so it will be updated to VSTS soon.starian chen-MSFT

2 Answers

3
votes

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.

2
votes

The Nuget restore task just includes Nuget.exe 3.3 and 3.5, so there isn’t the option of 4.0. You can check the files in [build agent folder]\tasks\NuGetInstaller\[version]\ node_modules\nuget-task-common\NuGet folder.

You can build a custom build/release task to include nuget.exe 4.0 and use this task instead. More information, you can refer to Add a build task.

On the other hand, you can add Nuget.exe to the source control, then map it to the build agent (Repository tab of build definition) and specify the path with built-in variable (e.g. $(build.sourcesdirectory))