I have a step in a simple yaml pipeline to install the Azure Sign Tool.
It installs it here but I do not have access /home/vsts/work/1/s.
Is there any way I can install the Azure Sign Tool to my local.
Maybe add a local path variable EF_BUILD_REPOSITORY_LOCAL and set it to my C:\temp folder?? Would that work?
- task: DotNetCoreCLI#2
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install azuresigntool --tool-path $($env:EF_BUILD_REPOSITORY_LOCALPATH) -v diag'
displayName: Install AzureSignTool
I suppose you install the tool in order to use it in the subsequent steps of the pipeline. In this case, you can try installing it globally:
dotnet tool install --global AzureSignTool
In this case, you don't have to specify the tool path, and you can use it by specifying just the name later:
AzureSignTool sign ...
You can try like as the following steps.
steps:
- task: UseDotNet#2
displayName: 'Use .NET Core sdk'
inputs:
packageType: 'sdk'
- task: DotNetCoreCLI#2
displayName: 'Install AzureSignTool'
inputs:
command: custom
custom: tool
arguments: 'install -g azuresigntool -v diag'
In addition, it seems that Azure Sign Tool is only supported on Windows. We could install the tool on Linux or macOS, but not use it.
Related
We have an ADO Build pipeline, which need download a nuget package from a remote feed.
Using a Windows agent, we can do something like
- task: NuGetCommand#2
displayName: Downloading nuget package
inputs:
command: custom
arguments: install "{{ parameters.packageName}}" d -source "${{ parameters.nugetFeed }}"
However, now we have switched to MarinerOS, which does not have mono installed, so nuget.exe is not working.
After searching around, DotNetCoreCLI#2 task is working in Linux OS, however in order to download a package, it needs a project file to be able to add the project reference and then restore the package.
- task: DotNetCoreCLI#2 // won't work as it cannot find any project files
displayName: Downloading nuget package
inputs:
command: 'custom'
arguments: package SomePackageName
vstsFeed: $(NugetFeed)
feedsToUse: 'select'
custom: 'add'
Since we do not have any project files nor solution files in our pipeline, how can we download a nuget package without Nuget.exe in ADO pipeline?
I need to use a task of az cli in a cloud agent, but need to use an older version, today the version used by default in windows-2019 image is az cli v.2.37.0, but I need az cli v.2.34.1.
How can I set this version in the task ?
You can install Azure CLI with the bash task.
# Specify python version
- task: UsePythonVersion#0
inputs:
versionSpec: '3.x'
architecture: 'x64'
# Update to latest Azure CLI version
- bash: pip install --pre azure-cli --extra-index-url https://azurecliprod.blob.core.windows.net/edge
displayName: 'Upgrade Azure CLI'
You can also specify a version for pip install.
- bash: pip install -Iv azure-cli==2.34.1 --extra-index-url https://azurecliprod.blob.core.windows.net/edge
displayName: 'Upgrade Azure CLI'
I am setting up an Azure Build pipeline to automatically build when a NuGet package get's published. In that build definition - I want to install the latest version of the package.
According to this answer, I need to restore packages first to authenticate against Dev Ops feeds.
I have set-up a build.yml file to include these tasks:
- task: DotNetCoreCLI#2
displayName: 'Restore Packages'
inputs:
command: restore
projects: web/*.csproj
vstsFeed: organizational-packages
- task: DotNetCoreCLI#2
displayName: Install Custom Internal Package Package
inputs:
command: 'custom'
custom: 'add'
arguments: 'package Custom.Internal.Package --prerelease'
projects: 'Web/*.csproj'
feedsToUse: 'select'
feedRestore: 'organizational-packages'
The NuGet feed is hosted in Azure Dev ops and has organizational scope.
When I go to run the build - the Azure Package feed is not included in the search for the package:
info : Adding PackageReference for package 'Custom.Internal.Package' into project
'/home/vsts/work/1/s/Project.Web/Web.csproj'.
info : GET https://api.nuget.org/v3/registration5-gz-semver2/custom.internal.package/index.json
info : NotFound https://api.nuget.org/v3/registration5-gz-semver2/cbh.surescripts.business/index.json 202ms
error: There are no versions available for the package 'Custom.Internal.Package'.
The package is located at https://myorg.pkgs.visualstudio.com/_packaging/organizational-packages/nuget/v3/index.json
I even tried accomplishing this with just the command line tasks:
- task: NuGetAuthenticate#0
displayName: Authenticate NuGet Feed
- task: CmdLine#2
displayName: Add Organizational Package Source
inputs:
script: 'dotnet nuget add source https://myorg.pkgs.visualstudio.com/_packaging/organizational-packages/nuget/v3/index.json -n credible'
- task: CmdLine#2
displayName: Install Custom Internal Package
inputs:
script: 'dotnet add package Custom.Internal.Package--prerelease'
workingDirectory: '$(Build.SourcesDirectory)/Web'
In the later case the package source is added - but I am getting an unauthorized error:
info : Adding PackageReference for package 'Custom.Internal.Package' into project '/home/vsts/work/1/s/Project.Web/Web.csproj'.
info : GET https://api.nuget.org/v3/registration5-gz-semver2/custom.internal.package/index.json
info : NotFound https://api.nuget.org/v3/registration5-gz-semver2/custom.internal.package/index.json 64ms
error: Unable to load the service index for source https://myorg.pkgs.visualstudio.com/_packaging/organziational-packages/nuget/v3/index.json.
error: Response status code does not indicate success: 401 (Unauthorized).
There is no feedsToUse in custom command in DotNetCoreCLI task, you could remove it, and try to add -v|--version <VERSION> to version the package:
- task: DotNetCoreCLI#2
displayName: 'dotnet custom'
inputs:
command: custom
projects: 'Web/*.csproj'
custom: add
arguments: 'package Custom.Internal.Package --prerelease -v 1.0.0'
As part of build I need to generate db migration script. I'm using Microsoft provided build agent
(only interesting part below)
pool:
vmImage: 'windows-2019'
- task: DotNetCoreCLI#2
displayName: Install dotnet-ef
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install dotnet-ef -g --version 5.0.0-preview.8.20407.4'
- task: DotNetCoreCLI#2
displayName: Generate migrations sql script
inputs:
command: 'custom'
custom: 'ef'
arguments: 'migrations script --project Web/Dal --startup-project Web/WebApi --configuration $(buildConfiguration) --context EmailContext --no-build --output $(Build.ArtifactStagingDirectory)/emailcontext-migrations.sql --idempotent --verbose'
dotnet-ef installation seems to work fine:
Tool 'dotnet-ef' (version '5.0.0-preview.8.20407.4') was successfully installed.
but it still fails from time to time with (more often recently) :
"C:\Program Files\dotnet\dotnet.exe" ef migrations script --project Web/Dal --startup-project Web/WebApi --configuration Release --context EmailContext --no-build --output D:\a\1\a/emailcontext-migrations.sql --idempotent --verbose
Could not execute because the specified command or file was not found.
Is there a problem with my build pipeline configuration?
If it fails from time to time I would rather say that this can be an issue with preview version.
Please add an next step after installing to list all globally installed tools:
dotnet tool list -g
You may also show us a log of installing tool for case when your pipeline doesn't work. To verify if you have this:
(We simply don't know it, since we can't check your logs).
And if it still happens I would encourage you to create an issue on GitHub.
From your description, this is an intermittent issue. So your pipeline configuration could be correct.
Could not execute because the specified command or file was not found.
This issue seems to be related to the dotnet-ef package installed.
As Krzysztof Madej's suggestion, this package version could cause this issue.
You could try to use the latest version: 5.0.0-rc.1.20451.13 or latest stable version: 3.1.8.
Here is a GitHub ticket with the same issue( Can't find the file after global installing dotnet-ef). You could follow it and check the update.
On the other hand, you could try to use the Command Line Task to install the dotnet-ef.
For example:
- task: CmdLine#2
inputs:
script: 'dotnet tool install --global dotnet-ef --version xxxx'
Is it possible to run a pre-release version of the DotNetCoreCLI task when writing an Azure Pipelines yaml script? I would like to use 3.0.1xx if possible to take advantage of dotnet tool update installing the tool rather than throwing an error if not installed.
If it is possible, what would the syntax be to make a call like this use a prerelease version rather than version 2:
- task: DotNetCoreCLI#2
continueOnError: true
inputs:
command: custom
custom: tool
arguments: install -g coverlet.console
displayName: Install Coverlet tool. This task will continue on error if coverlet is already installed.
you could use the following:
steps:
- task: UseDotNet#2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 3.0.101
installationPath: $(Agent.ToolsDirectory)/dotnet
possible versions: https://github.com/dotnet/core/blob/master/release-notes/releases-index.json
reading: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer?view=azure-devops