Skip to content

Instantly share code, notes, and snippets.

@heiswayi
Last active August 12, 2020 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heiswayi/7cd7c2b35215905531557444ad953eb1 to your computer and use it in GitHub Desktop.
Save heiswayi/7cd7c2b35215905531557444ad953eb1 to your computer and use it in GitHub Desktop.
MSBuild PowerShell script
# msbuild.ps1
[CmdletBinding(PositionalBinding = $false)]
param (
[ValidateSet('Build', 'Clean', 'Rebuild')]
[string]
$Target = 'Build',
[ValidateSet('Release', 'Debug')]
[string]
$Configuration = 'Release',
[ValidateSet('Mixed Platforms', 'Any CPU', 'x64', 'x86')]
[string] $Platform = 'Mixed Platforms',
[Parameter(ValueFromRemainingArguments = $true)]
[Alias('Args')]
[string[]] $ArgumentList
)
$MSBuildCmd = $(
Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0 |
Select-Object -ExpandProperty MSBuildToolsPath |
Join-Path -ChildPath MSBuild.exe
)
$MSBuildArgs = @(
, '/fl'
, '/flp:PerformanceSummary;Verbosity=normal'
, '/v:normal'
, '/tv:4.0'
, "/p:Configuration=${Configuration}"
, "/p:Platform=${Platform}"
, "/t:${Target}"
)
& $MSBuildCmd $MSBuildArgs $ArgumentList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment