Search code examples
tfsmsbuildcontinuous-integrationreleaseartifact

Obtain the artifact directory path as a relative path for the Release process


We are working on the configuration process for the Continuous Integration for some projects, we are using TFS and now we have a problem with some releases definitions. We want to use the Web Deploy package created in the Build process for the Deployment.

So far the build definition that we have is following:

enter image description here

The path for the creation of the package is the default, so we are able to find it inside the artifact directory. But the problem is when we nee extract the files in the target folder for the website in the server.

The Release definition that we are using is: enter image description here

In this part in the Download artifact phase the agent doing the release has access to the published files in the build process, so here we know where the .zip package is, and we can have the path using $(System.ArtifactsDirectory), but if we use Deploy IIS App task, as you can see we are connecting to the servers where we are doing the release and $(System.ArtifactsDirectory) give us the local address for the artifacts where the agents are configured, and the variable give the path like C:\agent_work\r1\a, where C is local for the agent, and the .zip file doesn't exist in that address. And we can't build a new path like \Myserver\$(System.ArtifactsDirectory).... , because $(System.ArtifactsDirectory) is an absolute path and as a result the whole path it is : \Myserver\C:\Myfolder....

We need other solution, we have considered in the build process create the package in a different folder, and in this case we always know where is the package, we aren't depending on the agent folders, and in this way we can use as Web Deploy Package path: \Myserver\packagefolder\file.zip, but we would like to use a different solution.

Is there any way to have the artifact folder with a relative path or something like this????


Solution

  • You could use Windows Machine File Copy task to copy the package file from agent to the servers where you are doing the release.

    Use this task to copy application files and other artifacts such as PowerShell scripts and PowerShell-DSC modules that are required to install the application on Windows Machines. It uses RoboCopy, the command-line utility built for fast copying of data.

    You could use a temporary folder handling the package file on the agent. Such as Build.StagingDirectory. Build variables

    Add a packagelocation such as /p:PackageLocation="$(Build.StagingDirectory)\\ in your MSbuild Arguments. Then copy the files from StagingDirectory to your local folder in remote server by using Windows Machine File Copy task.