开发者

How do I pass a property to MSBuild via command line that could be parsed into an item group?

I have the following MSBuild script:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Main" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">    
  <PropertyGroup>
    <build_configurations>test1;test2;test3</build_configurations>
  </PropertyGroup>    
  <ItemGroup>
    <BuildConfigurations Include="$(build_configurations)" />
  </ItemGroup>    
  <Target Name="Main">    
    <Message Text="Running with args: %(BuildConfigurations.Identity)" />
  </Target>
</Project>

If I invoke the script without any parameters, I get the expected response:

Running with args: test1
Running with args: test2
Running with args: test3

However, when I attempt to set the property via command-line like so:

msbuild [myscript] /p:build_configurations=test5%3btest6%3btest7

I get the following:

Running with args: test5;test6;test7

So, it's not batching as expected. I need to get MSBuild to create the item group with three items开发者_StackOverflow中文版 instead of one item. How should I do that? Thanks.

P.S. The following article basically addresses my question except the case where I want to pass semicolon-separated values: http://sedodream.com/CommentView,guid,096a2e3f-fcff-4715-8d00-73d8f2491a13.aspx


You've escaped the semicolons, preventing MSBuild from parsing them as individual items. Run like this instead, with quotes,

msbuild [myscript] /p:build_configurations="test5;test6;test7"

you will get the following output,

Running with args: test5
Running with args: test6
Running with args: test7
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜