MSBuild 烦恼(或者我的公然无知)
在重新设计我们的部署过程时,我转而使用 MSBuild 项目来代替现有的批处理文件。 所有主要元素都已就位,我本想删掉一两步,但遇到了障碍。
我正在使用组合路径任务创建一个名为 OutputPath 的属性,虽然在创建它后我可以毫无问题地访问它,但我不知道如何使用它来发挥我的优势。 考虑一下:
<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
<Output TaskParameter ="CombinedPaths" ItemName ="OutputFolder"/>
</CombinePath>
<MakeDir Directories="@(OutputFolder)" />
<MakeDir Directories="@(OutputFolder)\Foo" />
<MakeDir Directories="@(OutputFolder)\Bar" />
命令 2 和 3 失败,因为我正在引用一个数组并尝试与一个字符串连接。 创建属性并将其分配给 @(OutputFolder) 只会产生另一个项目组,而不是我可以使用 $ 访问器引用的属性。 我确实有一个丑陋的解决方法,但我很想澄清这一点。
谢谢,
-何塞
In reworking our deployment process I moved over to using an MSBuild project in place of our existing batch files. All of the major elements are in place, and I was looking to cut out a step or two but ran into a snag.
I'm creating a property called OutputPath using the CombinePath task, and, while I can access it with no issues after it has been created I'm at a loss as for how to use it to my advantage. Consider:
<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
<Output TaskParameter ="CombinedPaths" ItemName ="OutputFolder"/>
</CombinePath>
<MakeDir Directories="@(OutputFolder)" />
<MakeDir Directories="@(OutputFolder)\Foo" />
<MakeDir Directories="@(OutputFolder)\Bar" />
Commands 2 and 3 fail because I'm referencing an array and attempting to concatenate with a string. Creating a property and assigning it @(OutputFolder) simply results in another item group, not a property I can reference with the $ accessor. I do have an ugly workaround but I'd love to clear this up somewhat.
Thanks,
-Jose
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定确切的答案,但这里有一个想法:
本质上,如果您使用路径创建 OutputFolder 项目,它们将被附加到列表中。 顺便说一句,这必须位于元素中,并且您必须使用 Include=""。
I'm not sure of the answer exactly but here is an idea:
Essentially, if you create OutputFolder items with the path they will just be appended to the list. This would have to be in an element btw, and you have to use Include="".
噢! 绝对是无知,在输出元素上使用了错误的属性。
dOh! Definitely ignorance, used the wrong attribute on the Output element.