Project Description
A PowerShell module to make building projects with MsBuild easy. It provides many features like fire-and-forget, or build and wait to check if build succeeded.

The module builds using the Visual Studio Command Prompt when available in order to support more project types (e.g. XNA projects). When not using the -PassThru switch, it returns $true if the build succeeded, $false if it failed, and $null if we could not determine the build result. It also provides parameters for showing or hiding the build window, and automatically opening the error log when the build fails.

The module simply passes through any MsBuild command-line parameters you supply, so it supports all functionality (e.g. project types, targets, etc.) that you would get by calling MsBuild directly.

Here is an example of how to import the Invoke-MsBuild module into your powershell session and call it:
Import-Module -Name "PathTo_Invoke-MsBuild.psm1"
Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln"

Below are more examples of calling the module. For detailed information on the module's parameters, checkout the documentation.

$buildSucceeded = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln"

if ($buildSucceeded)
{ Write-Host "Build completed successfully." }
{ Write-Host "Build failed. Check the build log file for errors." }
$process = Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" -PassThru
Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln" -MsBuildParameters "/target:Clean;Build /property:Configuration=Release;Platform=""Mixed Platforms"" /verbosity:Quiet"
Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildWindowAndPromptForInputBeforeClosing -AutoLaunchBuildLog
Invoke-MsBuild -Path "C:\Some Folder\MyProject.vbproj" -BuildLogDirectoryPath "C:\BuildLogs" -KeepBuildLogOnSuccessfulBuilds -AutoLaunchBuildLog
Invoke-MsBuild -Path "C:\Database\Database.dbproj" -P "/t:Deploy /p:TargetDatabase=MyDatabase /p:TargetConnectionString=`"Data Source=DatabaseServerName`;Integrated Security=True`;Pooling=False`" /p:DeployToDatabase=True"
$logPath = Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath "C:\BuildLogs" -GetLogPath

Last edited Aug 6, 2013 at 5:24 PM by deadlydog, version 17