Dos Prompt - Batch file programming - Preparing executables for deployment(more straightforward way)
All I want to do is to get a set of binaries from projects in solution file (.NET win application) in the debug/release folder and put into one target folder so then I can quickly deploy into staging environment for testing.
I do not want to create the setup packages because I want to retain the pdb files in it (for debug version). I know this can be done using the package setup too and also some well build automation script to include debug database but too much of hassle and I want to do it across many projects. Also, I do not want to purchase another tool for simple stuff like this. All I want is a generic script for all kind of the projects.
So, here, I come out with a batch file
There are some approach in batch programming where a batch will read from another text file (the locations of the project). But i like to put all the location setting to the batch file. Easy to keep track and feel like in control all the time. Too many files to maintain not my preference that all.
Here goes the script.
I do not want to create the setup packages because I want to retain the pdb files in it (for debug version). I know this can be done using the package setup too and also some well build automation script to include debug database but too much of hassle and I want to do it across many projects. Also, I do not want to purchase another tool for simple stuff like this. All I want is a generic script for all kind of the projects.
So, here, I come out with a batch file
There are some approach in batch programming where a batch will read from another text file (the locations of the project). But i like to put all the location setting to the batch file. Easy to keep track and feel like in control all the time. Too many files to maintain not my preference that all.
Here goes the script.
cls
SET SOURCELOCATION="D:\Solution\"
SSET OUTPUTLOCATION="D:\Deployment"
SET FOLDER1=Project1
SET FOLDER2=Project2
SET FOLDER3=Project3
SET FOLDER4=Project4
SET FOLDER5=Project5
@echo off & setLocal EnableDELAYedeXpansion
pushd %SOURCELOCATION%
for /Lfor /L %%i in (1 1 5) do
(
echo.FOLDER%%i is !FOLDER%%i!
pushd !FOLDER%%i!
pushd "bin\Debug"
if not exist *.dll goto ERROR
mkdir %OUTPUTLOCATION%\!FOLDER%%i!
xcopy xcopy *.* %OUTPUTLOCATION%\!FOLDER%%i!
popd
popd
)
:QUIT echo Done EXIT /B 1
:ERROR echo Error occurredEXIT /B 1
Comments