blue piranha
blue piranha

Reputation: 3874

Unable to deploy app with nuget references on server

I am having a hard time deploying my first .net core app with nuget references on the server. Locally, the app works absolutely fine (able to use nuget packages).

Apparently, there is no packages.config. I am using Dapper, Newtonsoft.Json, etc. Where is the project storing reference to these packages? There is no packages folder.

In the solutions folder, there is nuget.config file which for some reason is empty.

What should I add here

enter image description here

Upvotes: 0

Views: 419

Answers (3)

Leo Liu
Leo Liu

Reputation: 76770

Unable to deploy app with nuget references on server

That because you are using the old version nuget restore task in the build pipeline, which only supports for the package management type packages.config not PackageReference.

That the reason why the old version task ask you to provide the path to the packages.config. The PackageReference is a follow-up product, so the previous version of nuget restore task does not support it.

Check the blog for some more details.

To resolve this issue, please use the V2 of the nuget restore task:

enter image description here

Note:

  • The PackageReference needs the nuget.exe 4.1 and above, please add a NuGet tool installer to install the nuget version above 4.1.
  • Using .NET Core restore task should be also work for this issue.

Update:

Yes, using TFS 2016

Since you are using TFS 2016, you could try to use the command line to invoke the nuget.exe to restore the package instead of the nuget installer task:

enter image description here

Download the nuget.exe above 4.0 from the nuget.org, then set it on the TFS server.

Hope this helps.

Upvotes: 1

Vova Bilyachat
Vova Bilyachat

Reputation: 19494

You should use task dotnetcorecli task which has

#command: 'build' # Options: build, push, pack, publish, restore, run, test, custom

Upvotes: 0

Victor Wilson
Victor Wilson

Reputation: 1846

You need to create a NuGet.config file that points to whatever NuGet feed you're using, add it to source control, and reference it in your build. I'll use the official feed for my example. This feed is already present by default if you're developing using Visual Studio, which might explain why the build runs locally but not on Azure DevOps.

At the very least, your NuGet.config file needs to look like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet.org Feed" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

In .NET Core, packages are now stored globally in your User directory. packages.config has been dropped in favor of the PackageReference node in a project file, so check your csproj to see the NuGets you're referencing.

Upvotes: 0

Related Questions