CommandLine Class | MSBuild Extension Pack Help 4.0.12.0 |
Launches command-line executables with robust warning and error message
integration in MSBuild and Visual Studio. This is an expanded version
of the Exec Task: http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx.
Inheritance Hierarchy
MSBuild.ExtensionPack.FrameworkCommandLine
Namespace: MSBuild.ExtensionPack.Framework
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0
The CommandLine type exposes the following members.
Constructors
Name | Description | |
---|---|---|
CommandLine |
Methods
Name | Description | |
---|---|---|
Execute |
Executes the build operation.
(Overrides TaskExecute.) |
Properties
Name | Description | |
---|---|---|
Command |
Gets or sets the command(s) to run. These can be system commands,
such as attrib, or an executable, such as program.exe, runprogram.bat, or setup.msi.
This parameter can contain multiple lines of commands (each command on a new-line).
Alternatively, you can place multiple commands in a batch file and run it using this parameter.
| |
CustomErrorRegularExpression |
Gets or sets the error regular expression.
Leaving this unset will result in no output errors.
| |
CustomWarningRegularExpression |
Gets or sets the warning regular expression.
Leaving this unset will result in no output warnings.
| |
ExitCode |
Gets the Int32 exit code provided by the executed command.
| |
IgnoreExitCode |
Gets or sets a value indicating whether to ignore the command exit code.
If true, the task ignores the exit code provided by the executed command.
Otherwise, the task returns false if the executed command returns an exit code
that does not match SuccessExitCode.
| |
IgnoreStandardErrorWarningFormat |
Gets or sets a value indicating whether the output is examined for
standard errors and warnings. This does not override errors and
warnings defined via CustomErrorRegularExpression and
CustomWarningRegularExpression.
| |
Outputs |
Gets or sets the output items from the task. The Execute task does not set these itself.
Instead, you can provide them as if it did set them, so that they can be used later in the project.
| |
StdErrEncoding |
Gets or sets the StdErr stream encoding. Specifies the encoding of the captured task standard error stream.
The default is the current console output encoding.
| |
StdOutEncoding |
Gets or sets the StdOut stream encoding. Specifies the encoding of the captured task standard output stream.
The default is the current console output encoding.
| |
SuccessExitCode |
Gets or sets the success exit code for the command. Default is zero (0).
| |
WorkingDirectory |
Gets or sets the directory in which the command will run.
|
Examples
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath> <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath> </PropertyGroup> <Import Project="$(TPath)"/> <Target Name="Default" DependsOnTargets="FxCop;JSLint"/> <Target Name="FxCop"> <PropertyGroup Condition="'$(FxCopEnabled)' == 'true'"> <!-- Regex for matching FxCop errors and warnings: filename(line,column) : warning|error :? CAxxxx : <error message> [Location not stored in Pdb] : warning|error :? CAxxxx : <error message> --> <FxCopErrorRegularExpression>(?imnx-s:^((\[Location\ not\ stored\ in\ Pdb\])|(Project)|((?<File>[^(]+)\((?<Line>\d+),(?<Column>\d+)\)))\s*:\s*\w+\s*:?\s*(?<Message>(?<ErrorCode>CA\d+)\s*:?\s*.*)$)</FxCopErrorRegularExpression> <TargetBinaryRoot Condition="'$(TargetBinaryRoot)' == ''"></TargetBinaryRoot> <TargetFileName Condition="'$(TargetFileName)' == ''"></TargetFileName> <PublicRoot Condition="'$(PublicRoot)' == ''"></PublicRoot> <FxCopVersion Condition="'$(FxCopVersion)' == ''">1.36</FxCopVersion> <!-- Build wide rule exclusions (format: -<Namespace>#<CheckId>, e.g., -Microsoft.Design#CA1020): None --> <FxCopRules Condition="'$(FxCopRules)' != ''">"/ruleid:$(FxCopRules)"</FxCopRules> </PropertyGroup> <!-- Use FxCopCmd.exe /? for information on the command-line switches used --> <MSBuild.ExtensionPack.Framework.CommandLine Command=""$(PublicRoot)\FxCop\$(FxCopVersion)\FxCopCmd.exe" /console /searchgac "/file:$(TargetBinaryRoot)\$(TargetFileName)" "/directory:$(TargetBinaryRoot)" $(FxCopRules)" CustomErrorRegularExpression="$(FxCopErrorRegularExpression)" ContinueOnError="true" /> </Target> <ItemDefinitionGroup> <JavaScript /> </ItemDefinitionGroup> <Target Name="JSLint"> <PropertyGroup> <!-- Regex for matching JSLint (http://www.jslint.com) errors and warnings: --> <JSLintErrorRegularExpression>(?imnx-s:^cscript\s+\"[^"]+\"\s+\<\"(?<File>[^"]+)\".*\bLint\s+[^\d]+(?<Line>\d+)[^\d]+(?<Column>\d+)\:\s+(?<Message>.*\n.*)$)</JSLintErrorRegularExpression> <PublicRoot Condition="'$(PublicRoot)' == ''"></PublicRoot> <JSLintVersion Condition="'$(JSLintVersion)' == ''">1.0</JSLintVersion> </PropertyGroup> <ItemGroup> <!-- Include all *.js files under the project folder and sub-folders Exclude all *.js files under the project bin, obj, or objd folders and sub-folders --> <JavaScript Include="**\*.js" Exclude="**\bin\**\*.js;**\obj\**\*.js;**\objd\**\*.js" /> </ItemGroup> <!-- Use cscript (Windows Script Host) to execute jslint.js --> <!-- Information on JSLint: http://www.jslint.com/lint.html --> <MSBuild.ExtensionPack.Framework.CommandLine Command=""cscript $(PublicRoot)\JSLint\$(JSLintVersion)\jslint.js" <"%(JavaScript.FullPath)"" CustomErrorRegularExpression="$(JSLintErrorRegularExpression)" ContinueOnError="true" /> </Target> </Project>
See Also