TFS Release Definition – Custom variables and values

Scenario – Sometimes we need to use some logic based data in a variable in Release definition task like datetime value. Example, You want to create backup folder with datetime folder to preserve the backups.

There is no direct way in TFS for achieving it. TFS does have some user defined variables that can be used for defined values but for such requirements in release, it does not have any.

To implement it, I did below steps –

  1. I defined variable in release definition and set the value to “none”. Example here is – backupfoldername and value is none.
  2. I added task for PowerShell script and added below Inline script to set the above defined variable with date time value –

$date= (Get-Date).ToString(‘MM.dd.yyyy-hhmmsstt’)

Write-Host “##vso[task.setvariable variable=backupfoldername]$date”

  1. Finally I added the release task where I wanted to use it and used it as $(variablename) like $(backupfoldername). It worked!

TFS RM–Kill Process before Copy Task


We need to copy the application executables and dlls to the XenApp environment or any other environment like Web server using TFS release manager.


Copying of executable files will fail if it is already in use as a process by some user.


To copy executable file, we need to ensure that it should not be in use. To ensure it, we need some script that detects it and if the process is running, it should kill it.

Here are the steps that can help to address the issue –

1) PowerShell script to kill the process. Here is the script that will kill the process –

   Script is to kill notepad* Process.
   Script is to kill notepad* Process.

#Script Name – KillProcess.ps1
$ProcessName = "notepad*"

$ProcessInfo = get-process | Where-object {$_.ProcessName -Like $ProcessName}
if (@($ProcessInfo).Count -gt 0)
    Write-Output "——-Process – $ProcessName —————"
    TASKKILL /F /T /IM $ProcessName
    Write-Output "Process – $ProcessName – killed successfully!" 
    Write-Output "————————————————–" 


2) Add this script in TFS application repository.

3) Publish it as an artifact in the application automated build definition so that it will be available for the release automation.

4) In release automation, add below tasks

       a. Task to copy the PowerShell script to the target machine.

       b. Task for “PowerShell on Target Machines”.


Output –



  ——-End of Article—–

Visual Studio 2017 – vNext Build Automation – .vdproj based installer

Problem – We need to build “.vdproj” (installer) based project in Visual Studio 2017 using vNext Build Automation.


Follow the below steps –

  1. First step is to configure the build environment.
    1. Install “Microsoft Visual Studio 2017 Installer Projects (InstallerProjects.vsix)”. Download it from
    2. To install it, double clink on InstallerProjects.vsix and follow the default option to complete the installation.
    3. Add the below highlighted key. To add it,
      1. Add the node 15.0_[User ID]_Config like as shown below 15.0_a71083cb_Config.
      2. Add MSBuild folder (key) in it.
      3. In MSBuild, create new key “EnableOutOfProcBuild” and set its value as 0.


  1. In TFS Build Definition, add task for command line and add the below information –
    1. ToolC:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\
    2. Arguments$(Build.SourcesDirectory)\Deployment.sln /build $(BuildConfiguration)
  2. Finally, initiate the build and it will build the “.vdproj” files as defined in the solution and will create MSI installer file.

TFS 2015–How to make check-in comments mandatory

To make check-in comments mandatory for all the developers, follow the below steps:

  1. From VS2015 Team Explorer tab, select “Settings” and  then select “Source Control” option.
  2. Source Control settings screen will appear, select “check-in policy” tab: image
  3. On Check-in policy tab, click on “Add” button. “Add check-in Policy” window will appear. Select “Changeset comments policy” and click Ok as shown below: clip_image001
  4. Once implemented, developers will be prompted below screen to enter the comments whenever they will do check-in activity:clip_image002

–End of Article—