Skip to content

Instantly share code, notes, and snippets.

@peitor
Created June 8, 2016 07:18
Show Gist options
  • Save peitor/2e0815c355db6205cf4b22ab680d71a0 to your computer and use it in GitHub Desktop.
Save peitor/2e0815c355db6205cf4b22ab680d71a0 to your computer and use it in GitHub Desktop.
REM Don't use this in Production!
REM Think about switching from MsDeploy to "MS Release Management" or even better: "Octopus Deploy" https://octopus.com/
REM ----------
REM In order for this to succeed:
REM * Run MsDeploy service on target machine
REM ----------
REM Writes log file to history.txt
REM On Success: Copies .zip files to Archive folder for later deployment
REM --------------
REM In order to do a rollback:
REM 1. Copy the 2 zip files (deployment packages) from the "archives" folder to this folder
REM SAMPLEAPPService.zip, SAMPLEAPPWeb.zip
REM 2. Change toWhere configuration setting
REM 3. Run "deploy-local-zip.bat"
REM @ECHO off
set Configuration=YOURSAMPLEAPP - Build and Test on Checkin
set debugOutput=-debug -verbose
set deploymentBaseFolder=c:\DataSAMPLEAPP\deployment\
set historyFolder=%deploymentBaseFolder%history
set archivesFolder=%deploymentBaseFolder%archives
set configurationFolder=%deploymentBaseFolder%Configuration
set BasePath=C:\Builds\4\SAMPLEAPP\%Configuration%\Binaries\_PublishedWebsites\
REM Make sure to set the variable in the other batch file
set Pass=MySecretPasswordToUse
@ECHO Deploying SAMPLEAPPService...
cd %BasePath%SAMPLEAPPService_Package
call SAMPLEAPPService.deploy.cmd /Y /M:https://Production:8172/MSDeploy.axd /U:Administrator /P:%Pass% /A:basic -allowUntrusted -setParamFile:%configurationFolder%\SAMPLEAPPService.Production.SetParameters.xml %debugOutput%
if NOT ERRORLEVEL 0 GOTO :EXITFAILLABEL
@ECHO Deploying SAMPLEAPPWeb...
cd %BasePath%SAMPLEAPPWeb_Package
call SAMPLEAPPWeb.deploy.cmd /Y /M:https://Production:8172/MSDeploy.axd /U:Administrator /P:%Pass% /A:basic -allowUntrusted -setParamFile:%configurationFolder%\SAMPLEAPPWeb.Production.SetParameters.xml %debugOutput%
if ERRORLEVEL 0 GOTO :EXITLOGOK
:EXITFAILLABEL
@ECHO FAIL!! %DATE% %TIME%, %USERDOMAIN%\%USERNAME%, Production, %Configuration% >> %historyFolder%\history.txt
GOTO :EXITLABEL
:EXITLOGOK
@ECHO %DATE% %TIME%, %USERDOMAIN%\%USERNAME%, Production, %Configuration% >> %historyFolder%\history.txt
@ECHO ON
REM On successful COPY deployment we archive the deployed .zip
cd %deploymentBaseFolder%
call ..\deployment-common\util-SetDateTimeFolder.bat
ECHO %dateTimeFolder%
echo D | xcopy /Y /I "%BasePath%SAMPLEAPPService_Package\SAMPLEAPPService.zip" "%archivesFolder%\Production\%dateTimeFolder%"
echo D | xcopy /Y /I "%BasePath%SAMPLEAPPWeb_Package\SAMPLEAPPWeb.zip" "%archivesFolder%\Production\%dateTimeFolder%"
:EXITLABEL
cd %deploymentBaseFolder%
-----------------------
SAMPLEAPPService.Production.SetParameters.xml
-----------------------
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="Default Web Site/SAMPLEAPPService" />
<setParameter name="SAMPLEAPPEntities-Web.config Connection String" value="metadata=res://*/SAMPLEAPPDB.csdl|res://*/SAMPLEAPPDB.ssdl|res://*/SAMPLEAPPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=(local);Initial Catalog=SAMPLEAPPDev;User Id=SAMPLEAPPPlusUser;password=SAMPLEAPPSuperSecret;MultipleActiveResultSets=True&quot;" />
<setParameter name="log4netwebconfig" value="Data Source=SQLDB;initial catalog=LogDB_FOR_Continuous;integrated security=false;persist security info=True;User ID=SAMPLEAPPUser;Password=SAMPLEAPPSecret" />
<setParameter name="log4netSmtpAppenderError" value="Production - Error occurred in SAMPLEAPPService" />
</parameters>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment