Friday, April 3, 2009

Test .NET solutions and SVN with powershell

Developer consultants are often working with several projects during each day, and between colleagues, and there is nothing wrong with that, as long that you have your projects in version control.

@ Ebita (where I work) we are using Subversion and Visual SVN for VS200x IDE and its working great.

Every time I have worked on a project I commit my changes, but to ensure that the projects still compiles in a fresh clean checkout, I check all the code out in a different folder and compiles the project.

This is a manual process "Click checkout,open solution in VS,Click Rebuild button,check for compilation errors"

I don't like manual processes, if it can be automated, why isnt it so?
I installed powershell on my new laptop a few days ago, and thought let me see how easy it can be done with that.

Here is the code

$svnProjectName = "test_svn_project"
$svnUserName = "foo"
$svnPassword = "bar"
$visualStudioSolutionName = "test.sln"
$CheckoutPath = "C:\test\testFolder"

"//////////////////////"

"Get project from svn"
"//////////////////////"
[diagnostics.process]::start("svn.exe","checkout svn://svn/$svnProjectName $CheckoutPath --username $svnUserName --password $svnPassword").WaitForExit()

"//////////////////////"
"Rebuild .NET..."
"//////////////////////"

c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe "$CheckoutPath\$visualStudioSolutionName" /t:Rebuild /p:Configuration=Release

"//////////////////////"
"Finsished test deleting project"
"//////////////////////"

rm $CheckoutPath -recurse -force

"//////////////////////"
" DONE "
"//////////////////////"


Happy shelling :-)

No comments:

Post a Comment