0
votes

It seems my team mates have turned off their nuget server and gone on holidays. I need a temporary work around so that my Azure Dev Ops build does not fail when restoring the nuget packages.

I have a local copy of the package at

C:\Users\kirst.nuget\packages\mypackagetemp

Which I want to publish to a temporary feed.

I read the instructions on publishing a package from the command line but am confused about step 6 Surely I dont need to set up the Project and restore packages as I already have the .nupkg

I tried the command

c:\nuget\nuget.exe push -Source "TempFeed" -ApiKey az mypackagetemp.nupkg

but got an error

unable to load the service index for source https://pkgs.dev.azure.com/mycompany/myproject/_packageing/TempFeed/nuget/v3/index.json

When I repeat the command I get a request for credentials When I put in the credentials I connect to Azure Dev Ops with they do not work.

[Update]

I was prompted for credentials.. reading up on it... so confusing.

[Update]

I upgraded nuget.exe from 5.1.0.6013 to the latest version 5.4.0.6315 This time I got a UI to log in and the message

Your package was pushed

However when the devops pipeline build runs I het a message

unable to load the service index for source
https://pkgs.dev.azure.com/mycompany/myproject/_packageing/TempFeed/nuget/v3/index.json

I guess I need to create an index.json file somehow.

My project is using a mynuget.config that has the following in the packagesources

 <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget" />

[Update]

I changed mynuget.config to have

  <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/v3/index.json" />

Now the dev ops build shows the message

Failed to retrieve information about 'Serilog.Enrichers.Thread' from remote source 'https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/FindPackagesById()?id="Serilog.Enrichers.Thread'', response status code does not indicate success: 404 (Not Found).)

My solution does use Serilog. I don't think the 3rd party package uses it.

[Update]

The next time I built I got a different error looking for WindowsAzure.Storage

I seem to get a different file causing the error each time I build the pipeline.

My project artifacts does have 2 feeds. The needed files are in the unselected feed.

[Update]

I tried editing mynuget.config to use index.json however I get a build error

The nuget command failed with exit code(1) and error(Unable to load the service index for source https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/v3/index.json. Response status code does not indicate success: 404 (Not Found - The feed with ID 'MyFeed' doesn't exist

[Update]

Because the new feed was project based I edited mynuget.config to have

  <add key="TempPackage" value="https://pkgs.dev.azure.com/mycompany/myproject/_packaging/myfeed/nuget/v3/index.json" />

Now it works!

1
See this, if you use nuget restore task or similar tasks, we can determine the feedstouse, select(use devops feed+nuget.org) or config(custom nuget.config file). And for the error you get, it means 401 Unauthorized. So it's a permission-related issue.LoLance
You can use the select way, and navigate to Artifacts=>feed settings=>permissions=>add user/groups=>add your current projectName build service as owner role to make sure your build have access to get the packages from your feed.LoLance
my temp feed is project scoped. I wonder if it needs to be organizationaly scopedKirsten Greed
1.If your temp feed and current build pipeline belongs to same project, then it should work. If your temp feed belongs to Project A while the build pipeline belongs to Project B, you should make sure Project A has added the Project B build service account as member so that project B's build pipeline can access feed from Project A. 2.And see my update in answer, you could use the select way instead of mynuget.config when configuring the restore task (using UI) , click the dropdown list of USe packages from Azure Artifacts/tfs feed, if you can find the required feed there or not?LoLance
My tempfeed belonged to the project but I still needed to mention the project name in mynuget.config. Perhaps this is because the project also used a company wide package.Kirsten Greed

1 Answers

1
votes

In Azure Devops web portal, for your current project, go Artifacts tab and make sure your packages like mypackagetemp.nupkg are available there.

enter image description here

For me, I have custom LibraryCore.nupkg pushed there. Now let's click the Connect to feed settings, choose nuget.exe and you can see:

enter image description here

Copy exactly same content to your own mynuget.config file. Then your build pipeline can access your published mypackagetemp.nupkg.

Failed to retrieve information about 'Serilog.Enrichers.Thread' from remote source 'https://pkgs.dev.azure.com/mycompany/_packaging/myfeed/nuget/FindPackagesById()?id="Serilog.Enrichers.Thread'', response status code does not indicate success: 404 (Not Found).)

The next time I built I got a different error looking for WindowsAzure.Storage

These packages(Serilog.Enrichers.Thread,WindowsAzure.Storage and ...) are all available in nuget.org, so you should also make sure you've add nuget.org as package source in your config file:

enter image description here

In addition:

According to your description, you only need to use your custom devops feed and other packages from nuget.org, apart from using your mynuget.config, you could configure your nuget restore task like this:

enter image description here

Choose devops feed directly(second red line) by Feeds I select here instead of Feeds in my Nuget.config. And check the Use packages from nuget.org checkbox. Then you can access the packages in custom feed and nuget.org during build.