Copy one file in target directory on deploy from visual studio team services
With the new web based build system you can use multiple patterns in a single step. Therefore you can do something like this for your case:
Project\bin\x86\Release\project.exe
SomeScripts\**\*
Or if you have the build platform and configuration in a variable (eg. BuildPlatform
/ BuildConfiguration
) which you also use in the build step you could use them in the pattern:
Project\bin\$(BuildPlatform)\$(BuildConfiguration)\project.exe
SomeScripts\**\*
If you want the project.exe
to be in the root instead of the structure you need to use a Copy Task
to stage your files in the desired structure first. 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.
You need to specify the copy root if you want to copy files only without folder structure. Since the project.exe is in a different path with script.ps1 file, you need to copy them in different copy task.
Following the steps below:
- Add a "Copy Files" step to copy "project.exe". Settings like following:
- Add a "Copy Files" step to copy "SomeScripts" folder. Settings like following:
- Add a "Copy and Publish Build Artifacts" step to copy these files to "drop". Settings like following:
Now you should get the things like following in drop folder:
Project.exe
SomeScripts
script.ps1
"Flatten Folders" option in "Advanced" section of "Copy Files" step.
If you are using TFS Online (Visual Studio Online) and don't need to copy the folder structure use "Flatten Folders" option in "Advanced" section of "Copy Files" step in your build definition