Reputation: 2451
I am running the following script https://github.com/RicoSuter/Namotion.Reflection/blob/master/azure-pipelines.yml for a CI build demo:
trigger:
branches:
include:
- master
- release
- refs/tags/*
pr:
- master
pool:
vmImage: 'ubuntu-latest'
variables:
BuildConfiguration: Release
Projects: '**/*.csproj'
steps:
# Install required SDKs and tools
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
packageType: 'sdk'
version: '2.2.203'
# Patch preview project versions (only when on master branch)
- task: CmdLine@2
displayName: 'Install DNT'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
script: 'npm i -g dotnettools'
- task: CmdLine@2
displayName: 'Update project version patch'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
script: 'dnt bump-versions patch'
failOnStderr: true
- task: CmdLine@2
displayName: 'Patch project version preview'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
script: 'dnt bump-versions preview "$(Build.BuildNumber)"'
failOnStderr: true
# Build and test
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(Projects)'
arguments: '--configuration $(BuildConfiguration)'
feedsToUse: 'select'
versioningScheme: 'off'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: '$(Projects)'
arguments: '--configuration $(BuildConfiguration) --collect "Code Coverage"'
publishTestResults: true
feedsToUse: 'select'
versioningScheme: 'off'
# Publish artifacts
- task: CopyFiles@2
displayName: 'Copy packages'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
Contents: '**/*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
I tried to adjust the vmImage to use ubuntu-latest
and adjusted the npm command so that it is prefixed with 'sudo', however on the command dnt bump-versions patch I get the error below:
##[section]Starting: Update project version patch
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.151.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
dnt bump-versions patch
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/29d33702-3084-4704-851f-a6f76f18f813.sh
DNT (DotNetTools) NPM CLI
Error:
An assembly specified in the application dependencies manifest (dnt.deps.json) was not found:
package: 'Microsoft.Build.Locator', version: '1.2.6'
path: 'lib/netcoreapp2.0/Microsoft.Build.Locator.dll'
child_process.js:660
throw err;
^
Error: Command failed: dotnet "/usr/local/lib/node_modules/dotnettools/bin/binaries/NetCore22/dnt.dll" bump-versions patch
at checkExecSyncError (child_process.js:621:11)
at Object.execSync (child_process.js:657:15)
at /usr/local/lib/node_modules/dotnettools/bin/dnt.js:52:11
at ChildProcess.exithandler (child_process.js:286:7)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
status: 140,
signal: null,
output: [ null, null, null ],
pid: 3784,
stdout: null,
stderr: null
}
##[error]Bash exited with code '1'.
##[error]Bash wrote one or more lines to the standard error stream.
##[section]Finishing: Update project version patch
Any ideas please? I am following this code from a tutorial, I am open to other yaml scripts.
Upvotes: 0
Views: 172
Reputation: 19026
The error you faced indeed caused by dotnettools
.
See this DNT#npm-cli-package. You can see that the requirement of dotnettool
is
.NET Core 2.2+ or NetFX 4.7.2 and Visual Studio 2019
BUT,
NetFX
is the one which unique for windows
. In another word, if you continue want to use dotnettool, you can not use Ubuntu
and MacOs
image because NetFX
is Windows-only.
So, here you can not apply the pipeline with Ubuntu agent.
Upvotes: 1