![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I needed an easy way to get all web applications in the solution to get precompiled and put into some specific folder along with some console applications when i compile solution in the Release mode. That way I could just zip the whole _Deploy folder and it's ready and easy to continue deploy onto test/production environment. The task was implemented using single batch file (*.bat or *.cmd) file.
For each project needed to appear in the _Deploy.zip we just add a Post-Build event with following command line
call "$(ProjectDir)..\ExternalDlls\RunBeforeDeploy.cmd" "$(ProjectDir)" $(ConfigurationName) $(ProjectName)
The essence of the solution is command line script RunBeforeDeploy.cmd. Here is how it looks.
rem Making files for deploy ...
echo on
cls
IF NOT %2 == Release GOTO end
set prjDir=%1
set prjDir=%prjDir:"=%
set dstDir=%prjDir%..\ExternalDlls\_Deploy\%3\
echo.%prjDir%
echo.%dstDir%
if not exist "%dstDir%" mkdir "%dstDir%"
if "a.%prjDir%" == "a" goto end
del "%dstDir%*.*" /F /Q /S
dir "%dstDir%*." /b > C:\deleteme_%3.txt
rem for /f %%a in (C:\deleteme_%3.txt) do (
FOR /D %%a in ("%dstDir%*") do (
rmdir /S /Q "%%a\"
)
del C:\deleteme_%3.txt
if exist "%prjDir%\web.config" (
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe" -p " %prjDir% " -v / " %dstDir% "
copy /Y "%prjDir%\web.config" "%dstDir%\web.config"
) ELSE (
rem copy /Y "%prjDir%\bin\Release\*" "%dstDir%\*"
xcopy /s/e "%prjDir%\bin\Release" "%dstDir%*"
)
echo Files for deploy are ready in "%dstDir%"!
:end