Search code examples
azure-devopsyamlazure-pipelines-release-pipelinebuild-pipeline

Copy File task failed with the error of Unhandled: Not found SourceFolder


I am very new CI/CD domain of Aure Dev Ops. So I Created a test ASP.NET MVC application. I checkedin the application in git repo at visual studio online. My build pipeline is working fine, but the ms build configuration of where my published files will be, seems to be not found. here is my msbuild configuration in my yml file:

msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'

And in my release pipeline, I am using a copy task with the following yml

steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)/deploy'
  inputs:
    SourceFolder: '$(build.artifactStagingDirectory)'
    TargetFolder: '$(Build.ArtifactStagingDirectory)/deploy'

and this is the error I get when I try to deploy the release:

 ##[error]Unhandled: Not found SourceFolder: D:\a\r1\a\$(build.artifactStagingDirectory)

Solution

  • Build.ArtifactStagingDirectory doesn't exist in a release pipeline. You need to use a Publish Build Artifacts task in your build pipeline, then download the artifacts using the Download Build Artifacts task in your release pipeline.