Cannot push packages to azure artifacts feed, keeps asking for credentials

Viewed 958

I have .nupkg files locally that I am trying to push to azure artifacts. I've been pushing packages before but for some reason it now stops working. I've got a feed setup and I got full owner privilege's to the feed in azure artifacts.

I've installed NuGet.CommandLine package to my project and I run the following command in the package manager console (the behaviour is duplicated when i run it from a windows command terminal)

nuget.exe push -ConfigFile "D:\Projects\myProj\NuGet.Config" -Source "Itm_Feed" -ApiKey az "D:\Projects\myProj\LocalPackages\ITM.VisiWin7.Common.2.12.0.nupkg" 
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\bin'.
Please provide credentials for: https://pkgs.dev.azure.com/tembogroup/HMI/_packaging/Itm_Feed/nuget/v3/index.json

Nuget.config

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <!-- NuGet packages are now stored globally, see: https://stackoverflow.com/a/35809007/4122889 -->
  <!-- see: https://stackoverflow.com/a/53451805/4122889 -->
  <config>
    <add key="globalPackagesFolder" value=".\Packages" />
    <add key="repositoryPath" value=".\Packages" />
  </config>
  
  <!-- Setup for local packages, not in a nuget source -->
  <packageSources>
    <add key="Itm_Feed" value="https://pkgs.dev.azure.com/organization/team/_packaging/Itm_Feed/nuget/v3/index.json" />
  </packageSources>

</configuration>

As you can see it keeps prompting me for credentials - which it did not do before when it was working.

2 Answers

the behaviour is duplicated when i run it from a windows command terminal

I could reproduce this issue when I use the Username and Password.

To solve this issue, you could try to use UserName + PAT (Personal Access Tokens).

For example:

enter image description here

On the other hand, if you need to enter the user name and password in the command line every time, it will be a little inconvenient.

So you could try to use the following command to add the packageSourceCredentials to the nuget.config file.

Nuget Command:

nuget sources update -name Itm_Feed -username 123 -password <PAT>

In this case, you could run the Nuget Push without add Username and PAT.

enter image description here

Note: Nuget Resource name cannot be purely numeric.

Using the Developer command line caused this problem for me. Creating a command prompt from Windows (not inside VS, i.e. not developer command line) works and I get a popup asking for credentials which allowed the package to be pushed

Related