Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet restore fails for private nuget packages

I developed a web api (.net core) in windows and hosting it in ubuntu server. My application needs packages from private nuget repository. I have set the package source as nuget config -Set RepoName=http://sample-nuget-repo.net/api/odata. I have verified with nuget resources. When I run dotnet restore, it gives me failure messages. Please help me if i am missing anything.

what is the location of nuget.config file in ubuntu (as in windows it is appdata/nuget/nuget.config)

like image 687
Shekhar Avatar asked May 03 '18 12:05

Shekhar


People also ask

How do I force a NuGet package to restore?

Restore by using MSBuild You can use msbuild -t:restore to restore packages in NuGet 4. x+ and MSBuild 15.1+, which are included with Visual Studio 2017 and higher. This command restores packages in projects that use PackageReference for package references.

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

Does dotnet restore use NuGet?

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file.

How do I install a private NuGet package?

Install packages from NuGet.orgNavigate to NuGet.org and search for the package you want to install. Select Package Manager, and then copy the Install-Package command. In Visual Studio, select Tools > NuGet Package Manager > Package Manager Console to open the package manager console.


1 Answers

You can define custom package sources in a NuGet.Config file in the root directory of your source control repository containing your source code. Then you do not need to configure it on every machine.

NuGet.Config:

<configuration>
    <packageSources>
        <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
        <add key="sample-nuget-repo" value="http://sample-nuget-repo.net/api/odata" />
    </packageSources>
</configuration>

When you run a nuget restore solution.sln or dotnet restore solution.sln the solution's directory will be checked first for a NuGet.Config file, then the directory above, all the way back to the root directory. Finally the NuGet.Config under the user's profile will be checked.

like image 164
Matt Ward Avatar answered Sep 29 '22 22:09

Matt Ward