Created
August 9, 2011 21:53
-
-
Save toddb/1135297 to your computer and use it in GitHub Desktop.
Sample install.bat for psake with environment handin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo. | |
echo Running as: | |
whoami | |
echo. | |
set application=%1 | |
if NOT '%application%'=='' GOTO :environmentcheck | |
:: Update the sites as needed | |
echo. | |
echo You have not provided an application. | |
echo. | |
echo 1: http://localhost [Dev] | |
echo 2: http://build.local[Build] | |
echo 3: http://test.local [Test] | |
echo 4: http://staging [Staging] | |
echo 5: http://prod [Prod] | |
echo or [type own eg http://sp.local] | |
echo. | |
set choice= | |
set /p choice=Choose the site or type your own: | |
if '%choice%'=='' GOTO :environmentcheck | |
if %choice% EQU 1 set application=http://localhost | |
if %choice% EQU 2 set application=http://build.local | |
if %choice% EQU 3 set application=http://test.local | |
if %choice% EQU 4 set application=http://staging | |
if %choice% EQU 5 set application=http://prod | |
echo. | |
@echo --- Using %choice%: %application% | |
:environmentcheck | |
set environment=%2 | |
if NOT '%environment%'=='' GOTO :workingdircheck | |
echo. | |
echo You have not provided an environment. | |
:: Update the environment as needed | |
echo. | |
echo 1: Dev | |
echo 2: Build | |
echo 3: Test | |
echo 4: PreProd | |
echo 5: Prod | |
echo. | |
set choice= | |
set /p choice=Choose the environment code: | |
if '%choice%'=='' GOTO :environmentcheck | |
if %choice% EQU 1 set environment=Dev | |
if %choice% EQU 2 set environment=Build | |
if %choice% EQU 3 set environment=Test | |
if %choice% EQU 4 set environment=PreProd | |
if %choice% EQU 5 set environment=Prod | |
echo. | |
@echo --- Using %choice%: %environment% | |
:workingdircheck | |
:: Allow for runas to pass in current directory to ensure working directory is correct | |
if '%3'=='' GOTO :install | |
echo. | |
echo Setting directory: %3 | |
set changedir=cd %3 | |
:install | |
echo. | |
echo starting powershell: Invoke-Psake Install -properties @{application='%application%';environment='%environment%'} | |
powershell -ExecutionPolicy Unrestricted -Command " &{ %changedir%; import-module .\lib\psake\psake.psm1; $psake.use_exit_on_error = $true; Start-Transcript -Path .\install.log; Invoke-Psake Install -properties @{application='%application%';environment='%environment%'}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment