TFS RM–Kill Process before Copy Task

Requirement

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

Problem

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

Solution

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 –

<#
.Synopsis
   Script is to kill notepad* Process.
.DESCRIPTION
   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”.

      image

Output –

image

 

  ——-End of Article—–

Advertisements

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.

Solution

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 https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.MicrosoftVisualStudio2017InstallerProjects.
    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.

          image

  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\devenv.com
    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—