quamotion / dotnet-packaging

Extensions for the .NET Core CLI which help packaging and publishing .NET Core applications
MIT License
652 stars 85 forks source link

Feature Request - docs - Add instructions to get this working in Azure DevOps #162

Open alexmarshall132 opened 4 years ago

alexmarshall132 commented 4 years ago

Using the current instructions for dotnet tool install does not work on Azure DevOps due to an unknown error. Can you please provide instructions that will work for using this tool with Azure DevOps pipelines ?

joncloud commented 4 years ago

I was able to get the tool to work in Azure DevOps by using the following script block (on ubuntu-latest):

dotnet tool install --global dotnet-zip
export PATH=$PATH:~/.dotnet/tools
dotnet zip --configuration $(buildConfiguration)

I think the core problem is that by default the dotnet tools path is not included on the image, and does not have to do with this tool itself. I found microsoft/azure-pipelines-task #12548, which is a similar problem with a different tool. I ran a test based on the issue's feedback, and it was also successful. For example see the following steps in the pipeline:

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.1.x'
  displayName: 'use .net 3.1.x'

- script: |
    dotnet tool install --global dotnet-zip
    dotnet zip --configuration $(buildConfiguration)
  displayName: 'dotnet zip $(buildConfiguration)'
alexmarshall132 commented 4 years ago

Thank you for responding @joncloud . Unfortunately for whatever reason doing a global install always fails for my organization's build machine images. After a lot of experimenting, I found that I had to create a tool manifest for my projects and then do a local tool install for the project. Here's what worked for me:


- task: DotNetCoreCLI@2
  displayName: 'Restore dotnet tools for various build tasks'
  inputs:
    command: 'custom'
    custom: 'tool'
    arguments: 'restore --tool-manifest "$(Build.SourcesDirectory)/dotnet-tools.json" --configfile "$(Build.SourcesDirectory)/nuget.config"'

- task: DotNetCoreCLI@2
  displayName: 'Run .deb packaging tool for linux-arm64'
  inputs:
    command: 'custom'
    custom: 'tool'
    arguments: 'run dotnet-deb -c Release -f netcoreapp3.1 -r linux-arm64'
    workingDirectory: '$(Build.SourcesDirectory)/MyProjectName'