In my TFS 2017 build definition, I am trying to copy a folder with a specific name (Package) towards my Artifacts directory. I am only interested in the specific folder itself, not in it's parent folders.
Can someone enlighten me on how I should make this work?
Current configuration for the Copy Files task: Source: $(agent.builddirectory) Contents: **\Package*** Target Folder: $(build.artifactstagingdirectory)\MyArtifact
This results in the following folderstructure while my only interest is the Package folder: \MyArtifact\folderX\s\folderY\folderZ\folderA\Package
With TFS2017update1 and above, VSTS, you could simply check Flatten Folders under Advanced option in Copy Files Task. The easiest solution for now.
This will flatten the folder structure and copy all files into the specified target folder.
Not sure if you are working on 2017 release version, and there is no Flatten Folders option. You need to specify the copy root if you want to copy files only without folder structure. You can use $(Build.StagingDirectory)
as a target for this. Afterwards use the Publish task with $(Build.StagingDirectory)
as copy root and publish everything from this root to the drop.
Detail step and screenshot please take a look at the answer from Eddie in this question: Copy one file in target directory on deploy from visual studio team services
If the relative path to "package" does not change, you can specify the detailed path in "Source" to achieve the feature you want.
For example, configure the Copy Files Task:
Source Folder to: $(agent.builddirectory)\folderY\folderZ\folderA\Package
Contents to: **
Target Folder to: $(build.artifactstagingdirectory)\MyArtifact\Package
You will get the folder structure you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With