开发者

external file to hold msbuild tasks

开发者 https://www.devze.com 2023-01-12 02:15 出处:网络
I have created some ms build tasks for my VS project. Rather than having to update the VS Project file with each of the tasks, is it possible to create an external file to hold the build tasks and re

I have created some ms build tasks for my VS project.

Rather than having to update the VS Project file with each of the tasks, is it possible to create an external file to hold the build tasks and reference 开发者_StackOverflow中文版it via the main project file?

Also, I have seen with nant, that you can create .bat file to run nant tasks. Is it possible to do similar with msbuild?


Yes. You can use the Import task:

<Import Project="PathToMyIncludeFile\Include.proj" />

And yes you can create a batch file to run msbuild. The syntax is

msbuild <project> /t:target[;target] /p:propertyname=propertyvalue

Where the targets are defined in the msbuild file and the properties are any properties defined in the file. If you don't specify a target, the default that is defined in the msbuild file element will be run. Here are a couple of examples:

So to run your build with the Clean, and Compile targets:

msbuild myproject.proj /t:Clean;Compile

Or to run your build with a target of Compile and a release configuration:

msbuild myproject.proj /t:Compile /p:Configuration=Release

Or to run your build with the default target and a set a version property:

msbuild myproject.proj /p:Version=2.0.0.1

Command line parameters take precedence over the values defined in the file. So in the example above if you had the version defined in the file as:

<PropertyGroup>
    <Version>1.0.0.0</Version>
<PropertyGroup>

The build would run with a configured version of 2.0.0.1

As usual, check out MSDN for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消