Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure devops: error NU1101: Unable to find package xxx. No packages exist with this id in source(s): nuget.org

I have a package I push to a private nuget feed. Then a few other projects reference these packages. All is good, except when I specify a wildcard, that only works in vs, but apparently not when restoring via an azure devops build:

this works:

<PackageReference Include="MyLibPackage" Version="1.0.0.114" />

but I get the unable to find package error on:

<PackageReference Include="MyLibPackage" Version="*" />

snippet of the dockerfile the restore task in azure devops runs:

# Install the Credential Provider to configure the access
RUN wget -qO- https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash

# Configure the environment variables
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"$feed\", \"password\":\"$pat\"}]}"

WORKDIR /src

COPY ["MyProject/MyProject.csproj", "MyProject/"]

RUN dotnet restore -s "$feed" "MyProject/MyProject.csproj"
like image 832
Elger Mensonides Avatar asked Nov 16 '22 06:11

Elger Mensonides


1 Answers

Azure devops: error NU1101: Unable to find package xxx. No packages exist with this id in source(s): nuget.org

I do not have much experience with Docker, I am not sure if this issue comes from docker container or dotnet restore itself.

But since you said in the comment:

Basically everyting except a hard version number fails.

So, I would like provide a workaround to resolve this issue, you can check if it works for you:

Since we have to use the hard version number, we could add one more command to update the package to the latest version, the command line like following:

RUN dotnet add package MyLibPackage -s "$feed"

And set the WORKDIR in the dockerfile where the project file is.

@Elger Mensonides, Thanks for Elger`s contribution for the correct command line.

If we do not specify the version in the command line, it will add the latest package to the project.

Check the document dotnet CLI – how to update a NuGet package and add a new NuGet package for some details.

Hope this can helps.

like image 189
Leo Liu-MSFT Avatar answered Jan 04 '23 23:01

Leo Liu-MSFT