How to use an Azure DevOps NuGet feed in Visual Studio Code and Visual Studio

If you want to use NuGet or npm packages from an Azure DevOps pipeline in Visual Studio Code, you can following these steps:

Prerequisites

You must first install the “Microsoft Azure Artifacts Credential Provider”.

https://github.com/Microsoft/artifacts-credprovider

On a Windows machine I installed it by:
– creating a file: C:\Temp\installcredprovider.ps1″.
– copying the code from “https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1” to it
– executed the file in a PowerShell prompt:

Set-Location "C:\Temp"
.\installcredprovider.ps1

Project

Add the feed to NuGet configuration

Add feed to your NuGet configuration by executing:

nuget.exe sources Add -Name “spike-feed” -Source “https://roelvanlisdonk.pkgs.visualstudio.com/_packaging/spike-feed/nuget/v3/index.json”

NOTE: use the exact line as found under > Artifacts > Connect to feed button:
In mine case: nuget.exe sources Add -Name “spike-feed” -Source “https://roelvanlisdonk.pkgs.visualstudio.com/_packaging/spike-feed/nuget/v3/index.json”

The name should really be the name of the feed, not some custom name.

Feed

Run dotnet restore once with –interactive to authenticate against the Azure DevOps feed

We have to execute dotnet restore with –interactive once, to authenticate against the Azure DevOps feed.

dotnet restore --interactive

After that you can use dotnet restore without manual authentication.
Now if you open the .NET Core solution in Visual Studio it will also work and you don’t have to do anything.

Sonar Cloud and Azure DevOps – Fixing [SQ] Task failed with status FAILED

A pull request build in Azure DevOps failed with the error: “[SQ] Task failed with status FAILED”.

This was the only information given, when de build failed.

Luckily, the manual build gave more information:

Error: /home/vsts/work/1/s/gradlew failed with return code: 1

FAILURE: Build failed with an exception.

2018-10-30T10:51:56.3943110Z

2018-10-30T10:51:56.3943526Z * What went wrong:

2018-10-30T10:51:56.3960616Z Execution failed for task ‘:sonarqube’.

2018-10-30T10:51:56.3961713Z > ‘feature/10691-fix-side-menu-not-working]-when-NOT-admin’ is not a valid branch name. It can only contain ‘A-Z’, ‘a-z’, ‘0-9’, ‘-‘, ‘_’, ‘.’, and ‘/’)

The problem was in the branch name, it accidentally contained a “]” character.