MSBuild 烦恼(或者我的公然无知)

发布于 2024-07-26 10:07:10 字数 711 浏览 7 评论 0原文

在重新设计我们的部署过程时,我转而使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不念旧人 2024-08-02 10:07:10

我不确定确切的答案,但这里有一个想法:

<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
  <Output TaskParameter ="CombinedPaths" ItemName ="OutputFolder"/>
</CombinePath>

<OutputFolder Include="$(DeployFolderRoot)$(DeployReleaseFolder)$(ReleaseFolderFormatted)\Foo" /> 
<OutputFolder Include="$(DeployFolderRoot)$(DeployReleaseFolder)$(ReleaseFolderFormatted)\Bar" />

<MakeDir Directories="@(OutputFolder)" />

本质上,如果您使用路径创建 OutputFolder 项目,它们将被附加到列表中。 顺便说一句,这必须位于元素中,并且您必须使用 Include=""。

I'm not sure of the answer exactly but here is an idea:

<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
  <Output TaskParameter ="CombinedPaths" ItemName ="OutputFolder"/>
</CombinePath>

<OutputFolder Include="$(DeployFolderRoot)$(DeployReleaseFolder)$(ReleaseFolderFormatted)\Foo" /> 
<OutputFolder Include="$(DeployFolderRoot)$(DeployReleaseFolder)$(ReleaseFolderFormatted)\Bar" />

<MakeDir Directories="@(OutputFolder)" />

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="".

浅唱々樱花落 2024-08-02 10:07:10

噢! 绝对是无知,在输出元素上使用了错误的属性。

<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
  <Output TaskParameter ="CombinedPaths" PropertyName="OutputFolder"/>
</CombinePath>

<MakeDir Directories="$(OutputFolder)" />
<MakeDir Directories="$(OutputFolder)\Foo" />
<MakeDir Directories="$(OutputFolder)\Bar" />

dOh! Definitely ignorance, used the wrong attribute on the Output element.

<CombinePath BasePath ="$(DeployFolderRoot)" Paths ="$(DeployReleaseFolder)$(ReleaseFolderFormatted)" >
  <Output TaskParameter ="CombinedPaths" PropertyName="OutputFolder"/>
</CombinePath>

<MakeDir Directories="$(OutputFolder)" />
<MakeDir Directories="$(OutputFolder)\Foo" />
<MakeDir Directories="$(OutputFolder)\Bar" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文