2

How to Install the Azure Artifacts Packages in VS Code, I tried to check the Connect to feed option and found there are multiple Nuget options like Dotnet, Nuget.exe, and Visual Studio, etc. But when I am trying for VS Code then it's not working.

What I did so far in the VS Code?

1 Approach) I install the NuGet package manager and when I am trying to do search my package then it's not showing in the list. but using this command "Get-PackageSource" I am able to see the package in the console.

2 Approach) I created one nuget.config file and mentioned below the package details

'<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="test@Release" value="https://xxxxxxx.pkgs.visualstudio.com/_packaging/test/nuget/v3/index.json" />
  </packageSources>
</configuration>'

after that running NuGet restore command and below giving the output but I didn't see any dependencies in the project and the same thing working fine using Visual Studio 2017

NuGet Config files used:

 C:\Users\sudhir\source\repos\testPrivateNugetFeed\NuGet.Config
    C:\Users\sudhir\AppData\Roaming\NuGet\NuGet.Config
    C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
    C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config

Feeds used: `https://XXXXX.pkgs.visualstudio.com/_packaging/test/nuget/v3/index.json' All projects are up-to-date for restore.

I have also followed this thread

Add custom package source to Visual Studio Code

Please give me some solution.

Sudhir Goswami
  • 125
  • 1
  • 9
  • Similar stack overflow question address here [Use of azure artifacts in VS code](https://stackoverflow.com/questions/54275063/connecting-to-an-azure-devops-private-nuget-in-vs-code) – Jatin Dave Nov 10 '20 at 18:24
  • Hi Jatin, even I followed the given article but what somehow its not working.. I am getting the PAT and after that trying to execute the nuget restore command but its' not working – Sudhir Goswami Nov 11 '20 at 03:30

1 Answers1

0

How to Install Azure Artifacts Packages dependencies in Vs Code?

I could reproduce this issue on my side, it seems to be a limitation of the NuGet package manager extension or Visual Studio Code.

No matter how I set up my Nuget.config file, I could not see the custom nuget package from the Azure devops feed in the NuGet package manager extension. I also test any other extension like NuGet Gallery, but not success.

To resolve this issue, I add following nuget.config file in my project, which next to my .sln file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AzureDevOpsFeed" value="https://pkgs.dev.azure.com/<MyORGName>/_packaging/<MyFeedName>/nuget/v3/index.json" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  
  <config>

</config>

  <packageSourceCredentials>
    <AzureDevOpsFeed>
      <add key="Username" value="LeoTest" />
      <add key="ClearTextPassword" value="My PAT Here" />
    </AzureDevOpsFeed>
  </packageSourceCredentials>


</configuration>

And add following in my packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="LibA" version="1.0.0" targetFramework="net461" />
</packages>

The LibA is a custom package in my Azure decops feed:

enter image description here

Then I use nuget.exe to restore the package for my project:

enter image description here

enter image description here

If nuget restore not work for you, please share the log for that command.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I am also getting the same message in the console but its not restoring anything in the packages folder. PS C:\Users\Sudhir\source\repos\testPrivateNugetFeed> .\nuget.exe restore "C:\Users\Sudhir\source\repos\testPrivateNugetFeed\testPrivateNugetFeed.sln" MSBuild auto-detection: using msbuild version '16.7.0.37604' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'. Restoring packages for C:\Users\Sudhir\source\repos\testPrivateNugetFeed\testPrivateNugetFeed.csproj... Committing restore... – Sudhir Goswami Nov 11 '20 at 08:17
  • Writing assets file to disk. Path: C:\Users\Sudhir\source\repos\testPrivateNugetFeed\obj\project.assets.json Restored C:\Users\Sudhir\source\repos\testPrivateNugetFeed\testPrivateNugetFeed.csproj (in 538 ms). NuGet Config files used: C:\Users\Sudhir\source\repos\testPrivateNugetFeed\NuGet.Config C:\Users\Sudhir\AppData\Roaming\NuGet\NuGet.Config C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config – Sudhir Goswami Nov 11 '20 at 08:17
  • Feeds used: C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ https://api.nuget.org/v3/index.json https://xxxx.pkgs.visualstudio.com/_packaging/test%40Release/nuget/v3/index.json https://xxxx.pkgs.visualstudio.com/_packaging/test@Release/nuget/v3/index.json – Sudhir Goswami Nov 11 '20 at 08:17
  • @SudhirGoswami, Is that all the log here? Would please remove the log in the comments and add it to your question, it well help us to read it, or you can share it with a image(Erase personal information). The log you provided does not show any information about your successful restore, only Writing assets file to disk – Leo Liu Nov 11 '20 at 08:27
  • @SudhirGoswami, And what is the version of your nuget.exe? Try to update the nuget.exe to latest version. – Leo Liu Nov 11 '20 at 08:44
  • I am using the latest nuget.exe only. So the issue is I am not able to see any dependencies in the package folder. – Sudhir Goswami Nov 11 '20 at 09:24
  • @SudhirGoswami, nuget do not restore any package in the packages folder or just not restore the dependencies in the package folder? Share the restore log with image will be better. Thanks. – Leo Liu Nov 11 '20 at 09:27