Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild task to execute an external MSBuild file

Tags:

msbuild

I'm trying to set up a MSBuild file which will invoke another MSBuild file and I'm wondering what's the best way to achieve this.

We're using it in the scenario of where a build server downloads a MSBuild file which then depending on the parameters it'll execute the appropriate 2nd file.

I know I can just use the <Exec Command="msbuild.exe ..." /> task, but that seems to be a bit of a hacky way to do it.

Is there an easier way to use MSBuild to execute another MSBuild file?

like image 595
Aaron Powell Avatar asked Oct 01 '09 04:10

Aaron Powell


People also ask

How do I run MSBuild task?

To execute a task in an MSBuild project file, create an element with the name of the task as a child of a Target element. If a task accepts parameters, these are passed as attributes of the element. Tasks can also return information to the project file, which can be stored in items or properties for later use.

How do I run MSBuild from command prompt?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

Which tasks in MSBuild can be used by developers in code with MSBuild?

MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed.

Which is the initial step needed when using the MSBuild at the command prompt?

Build the targettargets file. Run MSBuild from the Developer Command Prompt for Visual Studio to build the HelloWorld target defined above. Use the -target or -t command-line switch to select the target.


1 Answers

You can use the MSBuild task to build a target in another MSBuild project.

You can also put the target in an external .targets file that is imported by both MSBuild projects and use the CallTarget task to build it.

Update: To execute an external command, use the Exec task.

like image 160
Franci Penov Avatar answered Oct 14 '22 10:10

Franci Penov