THE NEED:
I wanted a quick bat file to publish a .net project I have to dev or test when the need arises. I also wanted make it kind of modular in case i need this for more projects.
THE SOLUTION:
The main bat file is store in a central location: C:\publishToLocation.bat
SET /P variable=Are you sure you wish to PUBLISH to server? (y/n)
IF /i NOT "%variable%"=="y" GOTO end_process
echo Publishing site %PROJECT_ROOT% to %WEB_ROOT%
DEL "%WEB_ROOT%" /Q || goto DeleteError
call %msBuildDir%\msbuild.exe "%PROJECT_ROOT%%FileName%" /t:Build;PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Release;AutoParameterizationWebConfigConnectionStrings=False;_PackageTempDir="%WEB_ROOT%" /v:quiet || goto Error
goto Success
:end_process
echo project not published
goto End
:Error
echo Error publishing project
goto End
:DeleteError
echo Could Not Empty Folder: "%WEB_ROOT%"
goto End
:Success
echo Project published successfully
:End
The next is a bat file I place on my desktop: publish[PROJECTNAME].bat
@ECHO OFF
SET msBuildDir=%WINDIR%\Microsoft.NET\Framework\v4.0.30319
SET WEB_ROOT=[DIRECTORY PATH TO DEPLOY TO]
SET PROJECT_ROOT=[DIRECTORY PATH TO PROJECT]
set FileName=[PROJECTFILENAME].csproj
call C:\_PROJECTS\Custom\publishToLocation.bat
Be careful not to leave spaces before or after variables