I achieved this by customizing our build process template. Make a copy of your DefaultTemplate.xaml (e.g. DefaultTemplateV2.xaml) and open it.
If you are new to xaml workflow editor, I find that it helps collapse all over again.
Once it opens, click the root sequence and click "Arguments". Add three arguments:
- DeployBuild (Boolean) Default False
- FromPath (String)
- InstallPath (String)
Then, in your workflow, open the following sections:
- Run agent
- Try compiling, testing and ...
- In the section "Try to open the sequence"
At the bottom of the sequence after receiving the trial, open the toolbar and drag the βIfβ work item. Set the condition to DeployBuild.
In the After section, drag and drop in the CopyDirectory workflow item. Set Destination for InstallPath and Source for
String.Format("{0}\{1}", BinariesDirectory, FromPath).
Save it and check it. You will need to open the previous assembly and mark the built-in assembly folder that you want to deploy. It will be something like _PublishedWebsites \ mywebsite \
Change the assembly definition (you may have to close and reopen VS) and go to the Process tab. Change the build process template to the new version.
Set the FromPath parameter to the path just specified. Install InstallPath in the UNC path to the target folder (you need to make sure that any service account that runs your builds has access to this path) and set DeployBuild to True.
Save, queue the assembly, and test the deployment.
You can also jump to arguments in your XAML workflow and edit the metadata argument with each of your new arguments. You can set where they can be viewed. Thus, you can, for example, install FromPath and InstallPath for viewing only when editing the definition, but DeployBuild will be displayed when the build is in order. This way you can turn it on or off in order of priority.
Good luck.