NuGroom is packaged as a .NET tool and can be installed and run directly in Azure DevOps pipelines.
UseDotNet task)dotnet tool install --global NuGroom
dotnet new tool-manifest # only once, creates .config/dotnet-tools.json
dotnet tool install NuGroom
If you publish the NuGet package to an Azure Artifacts feed:
dotnet tool install --global NuGroom \
--add-source https://pkgs.dev.azure.com/yourorg/_packaging/YourFeed/nuget/v3/index.json
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: nugroom --config settings.json
displayName: 'Scan repositories'
env:
ADO_PAT: $(System.AccessToken)
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: |
nugroom --config settings.json \
--export-packages $(Build.ArtifactStagingDirectory)/packages.json \
--export-warnings $(Build.ArtifactStagingDirectory)/warnings.json \
--export-sbom $(Build.ArtifactStagingDirectory)/sbom.spdx.json
displayName: 'Scan and export'
env:
ADO_PAT: $(System.AccessToken)
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'nugroom-reports'
trigger: none
schedules:
- cron: '0 6 * * Mon'
displayName: 'Weekly package update check'
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: |
nugroom --config settings.json \
--update-references \
--update-scope Patch
displayName: 'Update packages (Patch scope)'
env:
ADO_PAT: $(System.AccessToken)
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: |
nugroom --config settings.json \
--sync Newtonsoft.Json 13.0.3
displayName: 'Sync Newtonsoft.Json to 13.0.3'
env:
ADO_PAT: $(System.AccessToken)
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: |
nugroom --config settings.json \
--migrate-to-cpm --dry-run
displayName: 'Preview CPM migration'
env:
ADO_PAT: $(System.AccessToken)
Use --list-vulnerabilities as a pipeline gate to fail the build when vulnerable packages are detected. The tool exits with code 1 if any vulnerabilities are found.
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '10.x'
- script: dotnet tool install --global NuGroom
displayName: 'Install NuGroom'
- script: |
nugroom --config settings.json \
--list-vulnerabilities \
--export-vulnerabilities $(Build.ArtifactStagingDirectory)/vulnerabilities.json
displayName: 'Check for vulnerabilities'
env:
ADO_PAT: $(System.AccessToken)
- task: PublishBuildArtifacts@1
condition: failed()
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'vulnerability-report'
Use environment variable references in your config file to avoid storing secrets in source control. Map pipeline variables in the env block:
settings.json:
{
"Organization": "https://dev.azure.com/yourorg",
"Token": "$env:ADO_PAT",
"Feeds": [
{
"Name": "InternalFeed",
"Url": "https://pkgs.dev.azure.com/yourorg/_packaging/Feed/nuget/v3/index.json"
}
],
"FeedAuth": [
{
"FeedName": "InternalFeed",
"Username": "",
"Pat": "${FEED_PAT}"
}
]
}
Pipeline step:
- script: nugroom --config settings.json
displayName: 'Run NuGroom'
env:
ADO_PAT: $(System.AccessToken)
FEED_PAT: $(System.AccessToken)
The $(System.AccessToken) is automatically available in Azure DevOps pipelines and requires no manual PAT creation when the build service has the necessary permissions.
$(System.AccessToken)The default pipeline token has limited permissions. To use automated updates or PR creation, grant additional permissions to the Build Service identity:
ProjectName Build Service (OrgName))To build the .nupkg yourself:
dotnet pack NuGroom/NuGroom.csproj -c Release -o nupkg
This creates nupkg/NuGroom.0.1.0.nupkg. Push it to your Azure Artifacts feed:
dotnet nuget push nupkg/NuGroom.0.1.0.nupkg \
--source https://pkgs.dev.azure.com/yourorg/_packaging/YourFeed/nuget/v3/index.json \
--api-key az
See also: Getting Started · CLI Reference · Configuration