While PowerShell is great, I still do a lot of my build automation using plain old batch scripts when it comes to managing my SharePoint development workflow. Because I do my development outside of my SharePoint environment (develop on my host OS but SharePoint is in my guest OS), it requires some nifty batch scripts to keep the flow tight as no plugins or tools support this development model (dunno why...).
One of the challenges is making it easy to externalize environmental configuration information on a developer-by-developer basis.
In the past, I've relied on having team members create environment variables, but I decided to try out an external configuration file.
It worked out great 😀
The following script reads a file and sets four variables:
@ECHO OFF ECHO ______________________________________________ ECHO Setting up build environment... ECHO ______________________________________________ For /F "tokens=1-4* delims=;" %%A IN (..\build-configuration.txt) DO ( SET SERVER=%%A SET LOGIN=%%B SET PASSWORD=%%C SET APPPOOL=%%D ) ECHO SERVER = %SERVER% ECHO LOGIN = %LOGIN% ECHO PASSWORD = %PASSWORD% ECHO APPPOOL = %APPPOOL%
And the file looks like this:
vm1;administrator;P@ssw0rd;SharePoint - DM App Pool
Now I can use the variables like so:
ECHO ______________________________________________ ECHO Copy to remote server... ECHO ______________________________________________ IF NOT EXIST \\%SERVER%\_ic\ctmo\ GOTO END DEL \\%SERVER%\_ic\ctmo\binaries /q /s XCOPY ..\..\pkgs\*.* \\%SERVER%\_ic\ctmo /Y /I /S
It even works when calling to psexec:
ECHO ______________________________________________ ECHO Start psexec... ECHO ______________________________________________ ::// Deploys the binaries only (doesn't reinstall .wsp). ..\..\tools\sysinternals\psexec.exe \\%SERVER% -u %LOGIN% -p %PASSWORD% -e -d -w C:\_ic\ctmo\binaries cmd /c \\%SERVER%\_ic\ctmo\binaries\gac-install.bat
The best part is that each developer only has to create the text file and all of the environment specific information (like the target SharePoint server) are configured in one tiny file, allowing the automation scripts to be ready for any developer.