Wednesday, June 13, 2012

How to move Build file from one server to another server using Post Build Event in VS 2010


How to move Build file from one server to another server using Post Build Event in Visual Studio 2010

1.     Introduction
This document explains how to use How to move Build file from one server to another server using Post Build Event in VS 2010. The build file copy form source server to destination server with versioning. (i.e) here the version means we are creating a folder while build the solution with different name for each build.
2.       How to add BAT file in project.
In you solution Right click the Project ==> In that Context menu click Add ==> Then Click New Item in sub menu.

Then the Template Window will be open. In this window in Left pane side Select Visual C# ==>
In the right Select TextFile ==> Give your filename with .bat extensionèthen click save


3.       How to write commands in batch file
In your project you can able to see your newly added batch file. Open that batch file and add this below command in that file and save it.
@echo off

for /f "tokens=2* delims=:" %%a in ('echo %time%') do set mins=%%a
for /f "tokens=3* delims=:" %%a in ('echo %time%') do set sec=%%a
for /f "tokens=1* delims=." %%a in ('echo %sec%') do set secs=%%a
for /f "tokens=2* delims=." %%a in ('echo %sec%') do set mili=%%a
for /f "tokens=1* delims= " %%a in ('date/t') do set mmddyyyy=%%a
for /f "tokens=1* delims=." %%a in ('date/t') do set dd1=%%a
for /f "tokens=3* delims=." %%a in ('date/t') do set yyyy1=%%a
for /f "tokens=2* delims=." %%a in ('date/t') do set mm1=%%a
for /f "tokens=1* delims= " %%a in ('echo %yyyy1%') do set yyyy2=%%a
for /f "tokens=1* delims= " %%a in ('echo %~dp0') do set filePath=%%a


@echo on
SET date1=%yyyy2%%mm1%%dd1%%mins%%secs%%mili%
set filePath1=%filePath%
set solutionName=testBrTfs



xcopy "%filePath1%bin\debug\*.wsp" "\\DestinationServerName\SharedFolderName\%solutionname%\%date1%\"


4.       How to write Post Build Event Command
Right click your project in your solution ==> then click property.

In this Build window Click Build Events ==> In the Post-build event Command line section write the below command

if $(ConfigurationName) == Release call "$(ProjectDir)ReleaseBuild.bat"



5.       How to Release the Final Build
Before the final build your need to include the bin folder in that project and check out your “Release” folder in your project. And change the mode from “Debug” to “Release”

No comments:

Post a Comment