[personal profile] finesoul

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


If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Лютий 2022

Н П В С Ч П С
  12345
6789101112
13141516171819
202122232425 26
2728     

За стиль дякую

Створено з Dreamwidth Studios
Сторінка створена 2025-Чер-20, П'ятниця 13:19