0

We are in the process of trying out azure devops in the cloud for all our newest .NET core applications. One thing we need to be able to do is publish nuget packages from our on premise TFS 2017 instance, up to devops so the new apps can consume them. I created a new packages feed up in DevOps, and that gave me a URL to publish to. But when I try pushing up an existing package in a build, using a package publisher step, I get an error :

Response status code does not indicate success: 401 (Unauthorized).

Is this even possible? Anyone done this?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
evolmonster
  • 237
  • 1
  • 5
  • 16
  • Hello did you check this post, it lookssimilar to yours : https://stackoverflow.com/questions/37956817/unauthorized-nuget-package-from-visual-studio-team-services-using-asp-net-core-r – Jinja_dude Feb 01 '21 at 20:26
  • So I tried using "Connect to feed" in the VSTS instance, but it doesnt let me select a new feed. Or change the details of the feed. I also tried running a nuget command on the build server : nuget.exe sources Add And I can see the feed in the list using nuget.exe. But nothing has changed. Still wont authenticate. – evolmonster Feb 01 '21 at 21:44

1 Answers1

0

If you want to publish NuGet packages from on premise TFS 2017 instance to Azure DevOps service feed, you will need to upgrade it because the below NuGet service connection is not available in it. We test it in TFS 2019 and find this type and then follow below steps.

  1. Create a NuGet feed in Azure DevOps service, and then enable “Allow project-scoped builds” option for this feed permissions by following this doc: Package permissions in Azure Pipelines.
  2. Follow this doc: Use NuGet with Azure DevOps Services feeds, you will get the feed URL as below. enter image description here
  3. Create a PAT with full access in Azure DevOps service, and then create a NuGet service connection in on premise TFS project as below. enter image description here Please note that Feed URL come from Step2, Username is your username in Azure DevOps service and Password is the generated PAT.
  4. Follow this doc: Publish to NuGet feeds (YAML/Classic) to publish NUGet packages from on premise TFS instance to Azure DevOps service feed. The NuGet push task is set like below. enter image description here
Edward Han-MSFT
  • 2,879
  • 1
  • 4
  • 9
  • So I am having trouble with part 3 there. I am not sure how to create the devops nuget connection in TFS2017. If I click Connect To Feed, it doesnt show the same window you showed there. It doesnt allow me to change the URL and just points to the existing nuget that we have on premise. How do I get to that Add Nuget Service Connection? – evolmonster Feb 02 '21 at 15:35
  • So if I go to Services > New Service Endpoint I get a list of services I can add, and nuget isnt in the list. I can add a Generic endpoint, enter the details as above. Then I get this error in the build when publishing : This provider only handles URIs from the build's Team Project Collection Unable to load the service index for source https://pkgs.dev.azure.com/myDevops/_packaging/devops/nuget/v3/index.json. Response status code does not indicate success: 401 (Unauthorized). – evolmonster Feb 02 '21 at 18:47
  • Sorry for not pointing that the NuGet service connection is not available in TFS 2017, it can be available in later Azure DevOps Server 2019 and later. Otherwise you could clone your repository in TFS 2017 to Azure DevOps and then create corresponding build pipeline to build it and then publish NuGet package to Azure DevOps feed directly. – Edward Han-MSFT Feb 04 '21 at 08:17
  • It looks like it might be available in 2017.3 - looking at the release notes. We plan on trying an upgrade to see if that works. – evolmonster Feb 04 '21 at 14:19
  • The latest Azure DevOps Server 2020 has been released, you could follow this doc: https://learn.microsoft.com/en-us/azure/devops/server/upgrade/get-started?view=azure-devops-2020 to upgrade to this version. – Edward Han-MSFT Feb 05 '21 at 02:05
  • We plan on migrating to DevOps in the cloud at some point in the future. At the moment we are migrating one project at a time. So we do not want to upgrade our on premise right now to the latest. – evolmonster Feb 05 '21 at 15:34
  • So the latest thing I tried - adding the TFS build server user to the devops server. Gave it permissions to the nuget feed. Added a new PAT for that user. Created a new generic service connection in TFS2017 using that PAT and username. Still getting the same error - This provider only handles URIs from the build's Team Project Collection 401 (Unauthorized). – evolmonster Feb 05 '21 at 20:15
  • Yeah, I can see the same issue using the Generic service connection in TFS 2017, so I suggest that you upgrade to latest TFS 2020 and then use the NuGet service connection, or clone your repository in TFS 2017 to Azure DevOps directly and then build it push packages to Azure DevOps feed. – Edward Han-MSFT Feb 08 '21 at 06:11
  • We are not planning upgrading on premise to 2020 right now. Thats probably a bit too big of a disruptive jump for us. There must be a way to do it! I can push to devops using CLI manually on my machine. So the push up to the artifact works fine. Its just getting a build to do that! – evolmonster Feb 08 '21 at 15:13