-1

I'm trying to publish a couple of pipeline artifacts during a build so that I can use them in a build of another solution.

My first build builds and tests the soltuion using the following yaml

- stage: build_test_release
    displayName: Build
    pool:
      vmImage: 'windows-latest'
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'

    jobs:
      - job: build
        steps:
        - task: NuGetToolInstaller@1
        - task: NuGetCommand@2
          inputs:
            restoreSolution: '$(solution)'
        - task: VSBuild@1
          inputs:
            solution: '$(solution)'
            msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
            platform: '$(buildPlatform)'
            configuration: '$(buildConfiguration)'
        - task: VSTest@2
          inputs:
            platform: '$(buildPlatform)'
            configuration: '$(buildConfiguration)'

This all works great and I've been able to do deployments using this yaml in the same file

    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'azuresubscription'
        appType: 'webApp'
        WebAppName: 'webappname'
        deployToSlotOrASE: true
        ResourceGroupName: 'resourcegroupname'
        SlotName: 'staging'
        packageForLinux: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'

I'm now trying to publish some of the projects which were build as Pipeline Artifacts so that I can use them in the build of another solution which references them. The following publish task gives me the error:

"##[error]Path does not exist: D:\a\1\a**\projectToPublish.zip"

    - task: PublishPipelineArtifact@1
      inputs:
        targetPath: '$(build.artifactStagingDirectory)/**/projectToPublish.zip'
        artifact: 'artifactname'
        publishLocation: 'pipeline'

What am I missing here? I've been thinking of moving the projects which are referenced by both soltuions into their own solutions and adding them as nuget packages or something similar. The projects I am trying to publish as artifacts to be used in the second solution are both WCF Client projects.

Thanks!

2 Answers2

1

The issue is that the task you're using, Publish Pipeline Artifacts, does not support wildcards for the 'File or directory path' argument. For this task $(build.artifactStagingDirectory) is replaced with D:\a\1\a\, in the second directory named a Azure DevOps is looking for a sub directory named ** which does not exist and causes the shown error. The other task AzureRmWebAppDeployment@4 you're using does support wildcards.

See the image below, where Azure DevOps shows in the the UI that the PublishPipelineArtifact@1 task does not support wildcards in targetPath:

1

Second I'm wondering why you're using a wildcard, because the task VSBuild@1 will just drop the package in the build.artifactStagingDirectory which should make the path $(build.artifactStagingDirectory)/projectToPublish.zip to locate the package.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • Hello I am having a problem. Suppose I am having a simple web app and pushed it to Azure Repos. Now I set up a build pipeline using yaml and then I set up a release pipeline which will require an artifact from the build pipeline. So I am using PublishPipelineArtifact@1. The build pipeline runs fine but my release pipeline fails with error Deployment of msBuild generated package is not supported. Change package format or use Azure App Service Deploy task. D:\a\r1\a\_ReleasePipelines\drop\WebApp.zip. So how to provide artifact required by release pipeline in correct naming sequence – krr Nov 30 '22 at 06:03
0

In AzureRmWebAppDeployment@4 you have

'$(build.artifactStagingDirectory)/**/WebProjectToPublish.zip'

And in PublishPipelineArtifact@1 you have a different name

'$(build.artifactStagingDirectory)/**/projectToPublish.zip'
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107