-1

azure pipline yaml publish config


trigger:

  • testing

pool: vmImage: ubuntu-latest

variables: buildConfiguration: 'Release' PublishPath: '/home/iradmin/aaaa/my-proj'

- task: UseDotNet@2 
  displayName: "Building .NET Core 5.x sdk"
  inputs:
    version: '5.0.x'
    packageType: sdk


- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'

- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'Building'

- task: DotNetCoreCLI@2
  displayName: "Publish"
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/**/WebUI.csproj'
    arguments: '-r linux-x64 --configuration $(BuildConfiguration) --output $(PublishPath)'
    modifyOutputPath: false
    zipAfterPublish: false
    

all goes well but ... output error in publish step


2021-07-31T13:48:01.0670834Z /opt/hostedtoolcache/dotnet/sdk/5.0.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(111,5): error MSB3191: Unable to create directory "/home/iradmin/aaaa/my-proj/WebUI/". Access to the path '/home/iradmin/aaaa/my-proj/WebUI/' is denied. [/home/vsts/work/1/s/src/WebUI/WebUI.csproj] 2021-07-31T13:48:01.0704470Z ##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1 2021-07-31T13:48:01.0716597Z ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build 2021-07-31T13:48:01.0720360Z Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://learn.microsoft.com/en-us/dotnet/core/tools/ and https://learn.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting 2021-07-31T13:48:01.0723236Z ##[error]Dotnet command failed with non-zero exit code on the following projects : /home/vsts/work/1/s/src/WebUI/WebUI.csproj 2021-07-31T13:48:01.0727745Z ##[section]Finishing: Publish


thanks in advance

1 Answers1

0

The /home/iradmin/... output directory is probably not existing, or you do not have the rights to write onto it. In both cases, it's best to create new files and directories where you know you have proper access rights. On Azure DevOps agents this directory is certainly the one specified by the predefined variable Build.ArtifactStagingDirectory.

You can take a look to the https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#publish-projects-to-specified-folder, where the arguments are defined as follows:

 arguments: '-o $(Build.ArtifactStagingDirectory)/Output'

I'd suggest to rethink the PublishPath variable definition, and set its value to for example: $(Build.ArtifactStagingDirectory)/Output

Luca Cappa
  • 1,925
  • 1
  • 13
  • 23