Search code examples
tfsbuildpublishtfs-2015

TFS publish build artifacts to share with custom path


Is it possible to publish build artifacts with paths other than original?

I have built folders with all necessary files to publish:

  • SolutionName\Project1\bin\$(BuildConfiguration)
  • SolutionName\Project2\bin\$(BuildConfiguration)

I want to get:

  • \\share\$(Build.BuildNumber)\$(BuildConfiguration)/Project1 \\share\$(Build.BuildNumber)\$(BuildConfiguration)/Project2

In Publish build artifacts step I specified

  • Copy root SolutionName Content **\bin\$(BuildConfiguration)\*
  • Artifact Name $(Build.BuildNumber)
  • Path \\share

And get

  • \\share\$(Build.BuildNumber)\Project1\bin\$(BuildConfiguration)\...
  • \\share\$(Build.BuildNumber)\Project2\bin\$(BuildConfiguration)\...

Solution

  • You can use the Copy File task .In this task you could be able to the original directory structure and publish Build Artifacts through $(Build.StagingDirectory).

    See this question for details: Copy one file in target directory on deploy from visual studio team services


    Update

    enter image description here

    In your situation, the arguments should be(could change them based on your needs) :

    Two copy files task for each project:

    • Source Folder: $(Build.SourcesDirectory)\SolutionName\ProjectName\bin\$(BuildConfiguration)

    • Contents: **\*

    • Target Folder: $(Build.StagingDirectory)\$(Build.BuildNumber)\$(BuildConfiguration)\projectX

    One Copy and Publish Build Artifacts

    • Mostly the same with my screenshot above, Artifact Type should be File share and Path \\share

    Finally, you will get the result as below: enter image description here