runacustomtoolfrommyproject

Cancel
Save
Edit

Run a Custom Tool From my Project

If you convert an existing build process to *MSBuild*, you will probably have tools that you need to run during the build. The best way to run these tools is to write new MSBuild tasks that either include the tools or provide the same functionality. Some of the advantages of writing a task are:
* richer logging support
* type-safe task inputs and outputs
* multiple outputs from a task
However, if you do not have the resources to author a task immediately, or you need to continue to run your tool while the task is being authored, you can use the Exec task to run the tool. The Exec task runs a system command and also has a *WorkingDirectory* attribute that you can use to specify the directory in which the command will run. In this example, the Exec task runs a command to list all *DLLs* in the directory where the MSBuild binaries are located:

<Exec
Command="dir *.dll"
WorkingDirectory="$(MSBuildBinPath)"/>

Project Files

Download Code

<Project
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
		 		[DefaultTargets] = "Default">
	

<Target Name = "Default">

<!-- List the DLLs in the MSBuild directory -->
<Exec
Command = "dir *.dll"
WorkingDirectory="$(MSBuildBinPath)"/>
</Target>
</Project>