3

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.

sommmen
  • 6,570
  • 2
  • 30
  • 51

2 Answers2

6

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.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • 1
    Hm - too bad this just does not work out of the box like its described on azure artifacts (perhaps we need a little documentation there?). I've tried this way and it works however. Thanks for your efforts! – sommmen Nov 12 '20 at 08:25
  • Hi @sommmen. Please check this doc:https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/publish?view=azure-devops#publish-a-nuget-package-by-using-the-nuget-cli. It suggests that you could use username + PAT in Nuget CLI – Kevin Lu-MSFT Nov 12 '20 at 08:32
  • If the answer could solve your issue, you may consider accepting it. Thanks a lot. – Kevin Lu-MSFT Nov 12 '20 at 08:38
  • apologies, I meant the documentation page at https://dev.azure.com/tembogroup/HMI/_packaging?_a=connect&feed=Hmi_Feed It does not mention this possibility while it seems the 'this works most of the time' solution – sommmen Nov 12 '20 at 08:42
  • Thanks. Microsoft just ruined my scripts with this change. Thanks Obama. – Fabs Dec 21 '22 at 14:41
1

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

user1221237
  • 138
  • 8