Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2017 Build Copy Files without folder structure?

Tags:

tfs

tfsbuild

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

like image 966
Ben Thaens Avatar asked Dec 18 '22 03:12

Ben Thaens


2 Answers

With TFS2017update1 and above, VSTS, you could simply check Flatten Folders under Advanced option in Copy Files Task. The easiest solution for now.

enter image description here

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

like image 140
PatrickLu-MSFT Avatar answered Dec 28 '22 10:12

PatrickLu-MSFT


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.

like image 42
Eddie Chen - MSFT Avatar answered Dec 28 '22 09:12

Eddie Chen - MSFT