PowerBuild module provides full MSBuild integration into PowerShell pipeline. Unlike simmilar modules that provide wrapper around msbuild.exe
, PowerBuild's Invoke-MSBuild
cmdlet uses Microstft.Build
API directly. It means it can write build results into output, making the results available for processing by other cmdlets. Default logger utilizes Error, Warning and Verbose streams to log MSBuild events.
You can get the module from the PowerShell Gallery by executing following script.
Install-Module -Name PowerBuild
Invoke MSBuild and store results to local variable.
PS> $buildResults = Invoke-MSBuild -Project c:\Workspace\GitHub\kovalikp\PowerBuild\PowerBuild.sln `
>> -Target Build -Verbosity Minimal -ConsoleLogger PSHost `
>> -Property @{Configuration="Release"}
Manipulate results in pipeline.
PS> $buildResults | Select-Object -ExpandProperty Items | Format-Table ItemSpec,MetadataCount
CommandLine | PowerShell |
---|---|
[project file | directory] | -Project <string> |
/target:<targets> | -Target <string[]> |
/property:<n>=<v> | -Property <Hashtable> |
/property:Configuration=<v> | -Configuration <string> |
/property:Platform=<v> | -Platform <string> |
/maxcpucount[:n] | -MaxCpuCount <int> |
/toolsversion:<version> | -ToolsVersion <string> |
/verbosity:<level> | -Verbosity <LoggerVerbosity> |
/consoleloggerparameters:<parameters> | -ConsoleLoggerParameters <string> |
/noconsolelogger | -ConsoleLogger {None | PSStreams | PSHost} |
/fileLogger[n] | New-FileLogger |
/fileloggerparameters[n]:<parameters> | New-FileLogger |
/distributedlogger | |
/distributedFileLogger | |
/logger:<logger> | -Logger <ILogger[]> |
/binaryLogger | New-BinaryLogger |
/binaryLogger:<parameters> | New-BinaryLogger |
/warnaserror | -WarningsAsErrors @() |
/warnaserror:code[;code2] | -WarningsAsErrors <string[]> |
/warnasmessage | -WarningsAsMessages @() |
/warnasmessage:code[;code2] | -WarningsAsMessages <string[]> |
/validate | |
/validate:<schema> | |
/ignoreprojectextensions:<extensions> | -IgnoreProjectExtensions <string[]> |
/nodeReuse:<parameters> | -NodeReuse <bool> |
/preprocess | Invoke-MSBuildPreprocess |
/preprocess:file | Invoke-MSBuildPreprocess -OutputFile <string> |
/detailedsummary | -DetailedSummary |
@<file> | |
/noautoresponse | |
/nologo | |
/version | |
/help | Get-Help Invoke-MSBuild |
PowerBuild provides autocompleters for several arguments. They either use MSBuild API directly, or try to approximate MSBuild functionality to generate values.
Parameter | Solution | Project |
---|---|---|
Target | Metaproject + API | MSBuild API |
Configuration | MSBuild API | "Debug" or "Release" |
Platform | MSBuild API | "AnyCPU", "x64" or "x86" |
Default logger can be specified using -ConsoleLogger
parameter. The parameter currently recognized these values.
- $null - If console logger was passed via -Logger parameter, then
None
, elsePSStreams
. - PSStreams - Uses Error, Warning and Verbose streams to write logs.
-Verbosity
switch affects log level output to Verbose stream. - PSHost - Uses PowerShell host to write logs. This is equivalent of msbuild.exe's console logger.
- None - Disables console logger.
Level of logging is affected by -Verbose
parameter.
Additional loggers can be created using New-Logger
, New-ConsoleLogger
, New-FileLogger
, New-BinaryLogger
or New-StructuredLogger
commnandlets and passed to -Logger
parameter.