Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
Previous Versions
.NET Framework 2.0
General Reference
MSBuild Reference
Task Reference
 Exec Task

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
.NET Framework General Reference 
Exec Task 

Runs the specified program or command with the specified arguments.

The following table describes the parameters for the Exec task.

Parameter Description

Command

Required String parameter.

The command to run. This can be a system command, such as attrib, or an executable, such as program.exe.

ExitCode

Optional Int32 output read-only parameter.

Specifies the exit code provided by the executed command.

IgnoreExitCode

Optional Boolean parameter.

If true, the task ignores the exit code provided by the executed command. Otherwise, the task returns false if the executed command returns a non-zero exit code.

Outputs

Optional ITaskItem[] output parameter.

Contains the output items from the task. The Exec 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

Optional String output parameter.

Specifies the encoding of the captured task standard error stream. The default is the current console output encoding.

StdOutEncoding

Optional String output parameter.

Specifies the encoding of the captured task standard output stream. The default is the current console output encoding.

Timeout

Optional Int32 parameter.

Specifies the amount of time, in milliseconds, after which the task executable is terminated. The default value is Int.MaxValue, indicating that there is no time out period.

ToolPath

Optional String parameter.

Specifies the location from where the task will load the underlying executable file (cmd.exe).

WorkingDirectory

Optional String parameter.

Specifies the directory in which the command will run.

This task is useful when a specific MSBuild task for the job that you want to perform is not available. One disadvantage of using the Exec task rather than a more specific task is that it cannot gather output from the tool or command that it runs.

The Exec task calls cmd.exe instead of directly invoking a process.

The following example uses the Exec task to run a command.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <Binaries Include="*.dll;*.exe"/>
    </ItemGroup>

    <Target Name="SetACL">
        <!-- set security on binaries-->
        <Exec Command="echo y| cacls %(Binaries.Identity) /G everyone:R"/>
    </Target>

</Project>

Concepts

MSBuild Tasks

Other Resources

MSBuild Task Reference

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker