Search code examples
azure-devopsnugetazure-pipelinesazure-pipelines-build-taskazure-pipelines-tasks

Using Build.ArtifactStagingDirectory and PublishPipelineArtifact in a Matrix Build


My Azure Pipelines build outputs NuGet packages in the /home/vsts/work/1/Windows folder where Windows is a matrix name (I'm running the build section of my pipeline on Windows, Mac and Linux but want to publish the NuGet packages only from my Windows build).

The docs talk about using the $(Build.ArtifactStagingDirectory)/*.nupkg path to pass to NuGetCommand@2. However, this points to the /home/vsts/work/1/a folder.

Is the $(Build.ArtifactStagingDirectory) variable wrong because I'm using a matrix build? Is it wrong because I'm using the PublishPipelineArtifact@0 task to publish my .nupkg's?

Here is a link to my azure-pipelines.yml file.


Solution

  • Because you're using the matrix strategy with PublishArtifacts, you have multiple artifacts, so in the second stage (the deployment stage) the 3 artifacts are downloaded not to folder a in the agent, but to the root build folder:

        home
        |-- vsts
          |-- work
            |-- 1
              |-- a
                  b
                  s
                  Test Results
                  Mac
                  Ubuntu
                  Windows
    

    So you need to combine the variable $(Build.BuildDirectory) (home/vsts/work/1) with /Windows/.nupkg, like so:

    $(Build.BuildDirectory)/Windows/.npukg