All Projects → deadlydog → Invoke Msbuild

deadlydog / Invoke Msbuild

Licence: mit
Invoke-MsBuild PowerShell module to make building projects and solutions with MsBuild.exe easy.

Programming Languages

powershell
5483 projects

Projects that are alternatives of or similar to Invoke Msbuild

Water Monitoring System
Water Monitoring System is an IOT based Liquid Level Monitoring system that has mechanisms to keep the user alerted in case of liquid overflow or when tank depletes.
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Python Seabreeze
Python module for oceanoptics spectrometers
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Hacktoberfest2020 ccs
This is the repository for Hacktoberfest 2020
Stars: ✭ 123 (+0%)
Mutual labels:  hacktoberfest
Pathlengthchecker
Path Length Checker is a stand-alone app that returns the paths and length of all files and directories in a given directory.
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Bitfield
🍰 bit field diagram renderer
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Logrotate
Development repository for the logrotate cookbook
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Fabric Gateway Java
Hyperledger Fabric Gateway SDK for Java https://wiki.hyperledger.org/display/fabric
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Mobile Wallet
A reference implementation of Mifos platform wallet and payment capabilities
Stars: ✭ 123 (+0%)
Mutual labels:  hacktoberfest
Box Java Sdk
The Box SDK for Java.
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Chameleon
Fast HTML/XML template engine for Python
Stars: ✭ 121 (-1.63%)
Mutual labels:  hacktoberfest
Ansible Openwisp2 Imagegenerator
Automatically build several openwisp2 firmware images for different organizations while keeping track of their differences
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Js Nightwatch Recorder
🌙 ⌚️ NightwatchJs recorder for Chrome
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Laravel Mail Editor
MailEclipse ⚡ Laravel Mailable Editor!
Stars: ✭ 1,714 (+1293.5%)
Mutual labels:  hacktoberfest
Patternlab Edition Node Webpack
The webpack wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Hackatalk
TalkTalk renewal. Open source chat app built-in expo managed work flow
Stars: ✭ 123 (+0%)
Mutual labels:  hacktoberfest
Https Localhost
HTTPS server running on localhost
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Igor
Integration with Jenkins and Git for Spinnaker
Stars: ✭ 122 (-0.81%)
Mutual labels:  hacktoberfest
Ortelius
Ortelius simplifies the implementation of microservices. By providing a central catalog of services with their deployment specs, application teams can easily consume and deploy services across cluster. Ortelius tracks application versions based on service updates and maps their service dependencies eliminating confusion and guess work.
Stars: ✭ 123 (+0%)
Mutual labels:  hacktoberfest
Onramp
Easing the onramp for new or non-PHP developers to become Laravel devs.
Stars: ✭ 123 (+0%)
Mutual labels:  hacktoberfest
Algorithm Archive
A collaborative book on algorithms
Stars: ✭ 1,880 (+1428.46%)
Mutual labels:  hacktoberfest

Invoke-MsBuild PowerShell Module

A PowerShell module to make building projects and solutions with MsBuild easy. It provides features such as:

  • Check if the build succeeded or failed
  • Automatically open the build log file when the build fails
  • View the build output in the current console window, a new window, or not at all
  • Fire-and-forget building (via the -PassThru switch)

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. The module builds using the Visual Studio Command Prompt when available in order to support more project types that MsBuild.exe alone may not support, such as XNA projects.

Getting Started

You can either download the Invoke-MsBuild.psm1 file from the Releases page directly, or install the module from the PowerShell Gallery.

Here is an example of how to import the Invoke-MsBuild module into your powershell session and call it:

Import-Module -Name "C:\PathTo\Invoke-MsBuild.psm1"
Invoke-MsBuild -Path "C:\Some Folder\MySolution.sln"

When the -PassThru switch is provided, the process being used to run MsBuild.exe is returned.

When the -PassThru switch is not provided, a hash table with the following properties is returned:

  • BuildSucceeded = $true if the build passed, $false if the build failed, and $null if we are not sure.
  • BuildLogFilePath = The path to the build's log file.
  • BuildErrorsLogFilePath = The path to the build's error log file.
  • ItemToBuildFilePath = The item that MsBuild ran against.
  • CommandUsedToBuild = The full command that was used to invoke MsBuild. This can be useful for inspecting what parameters are passed to MsBuild.exe.
  • Message = A message describing any problems that were encountered by Invoke-MsBuild. This is typically an empty string unless something went wrong.
  • MsBuildProcess = The process that was used to execute MsBuild.exe.
  • BuildDuration = The amount of time the build took to complete, represented as a TimeSpan.

Examples

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

if ($buildResult.BuildSucceeded -eq $true)
{
  Write-Output ("Build completed successfully in {0:N1} seconds." -f $buildResult.BuildDuration.TotalSeconds)
}
elseif ($buildResult.BuildSucceeded -eq $false)
{
  Write-Output ("Build failed after {0:N1} seconds. Check the build log file '$($buildResult.BuildLogFilePath)' for errors." -f $buildResult.BuildDuration.TotalSeconds)
}
elseif ($null -eq $buildResult.BuildSucceeded)
{
  Write-Output "Unsure if build passed or failed: $($buildResult.Message)"
}

Perform the default MsBuild actions on the Visual Studio solution to build the projects in it, and returns a hash table containing the results. The PowerShell script will halt execution until MsBuild completes.


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

while (!$process.HasExited)
{
  Write-Host "Solution is still building..."
  Start-Sleep -Seconds 1
}

Perform the default MsBuild actions on the Visual Studio solution to build the projects in it. The PowerShell script will not halt execution; instead it will return the process running MsBuild.exe back to the caller while the build is performed. You can check the process's HasExited property to check if the build has completed yet or not.


if ((Invoke-MsBuild -Path $pathToSolution).BuildSucceeded -eq $true)
{
  Write-Output "Build completed successfully."
}

Perform the build against the file specified at $pathToSolution and checks it for success in a single line.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -MsBuildParameters "/target:Clean;Build" -ShowBuildOutputInNewWindow

Cleans then Builds the given C# project. A window displaying the output from MsBuild will be shown so the user can view the progress of the build without it polluting their current terminal window.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInCurrentWindow

Builds the given C# project and displays the output from MsBuild in the current terminal window.


Invoke-MsBuild -Path "C:\MySolution.sln" -MsBuildParameters "/target:Clean;Build /property:Configuration=Release;Platform=x64;BuildInParallel=true /verbosity:Detailed /maxcpucount"

Cleans then Builds the given solution, specifying to build the project in parallel in the Release configuration for the x64 platform. Here the shorter "Params" alias is used instead of the full "MsBuildParameters" parameter name.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -ShowBuildOutputInNewWindow -PromptForInputBeforeClosing -AutoLaunchBuildLogOnFailure

Builds the given C# project. A window displaying the output from MsBuild will be shown so the user can view the progress of the build, and it will not close until the user gives the window some input after the build completes. This function will also not return until the user gives the window some input, halting the powershell script execution. If the build fails, the build log will automatically be opened in the default text viewer.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath "C:\BuildLogs" -KeepBuildLogOnSuccessfulBuilds -AutoLaunchBuildErrorsLogOnFailure

Builds the given C# project. The build log will be saved in "C:\BuildLogs", and they will not be automatically deleted even if the build succeeds. If the build fails, the build errors log will automatically be opened in the default text viewer.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -BuildLogDirectoryPath PathDirectory

Builds the given C# project. The keyword 'PathDirectory' is used, so the build log will be saved in "C:\Some Folder", which is the same directory as the project being built (i.e. directory specified in the Path).


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"

Deploy the Visual Studio Database Project to the database "MyDatabase". Here the shorter "P" alias is used instead of the full "MsBuildParameters" parameter name. The shorter alias' of the MsBuild parameters are also used; "/t" instead of "/target", and "/p" instead of "/property".


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" -WhatIf

Returns the result object containing the same property values that would be created if the build was ran with the same parameters. The BuildSucceeded property will be $null since no build will actually be invoked. This will display all of the returned object's properties and their values.


Invoke-MsBuild -Path "C:\Some Folder\MyProject.csproj" > $null

Builds the given C# project, discarding the result object and not displaying its properties.

Full Documentation

For a full list of available parameters, check out the latest documentation in PowerShell by using Get-Help Invoke-MsBuild -Full, or just look at the file in source control here.

Changelog

See what's changed in the application over time by viewing the changelog.

Donate

Buy me some pancakes 🥞 for providing this PowerShell module open source and for free :)

paypal

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].