如何在不执行构建的情况下检索@(TargetOutputs)

发布于 2024-12-10 19:08:30 字数 776 浏览 1 评论 0原文

我正在实现一个 MSBuild 框架来驱动许多按层次结构组织的项目的构建和部署。

<Target Name="_CoreBuild">
  <MSBuild Projects="@(Project)" Targets="Build" Properties="Configuration=$(Configuration)">
    <Output TaskParameter="TargetOutputs" ItemName="CompiledAssemblies" />
  </MSBuild>
</Target>

为了实现正确的 Clean/Clobber 逻辑,我想检索如果使用当前选项执行构建则将编译的文件列表。

<Target Name="_CoreClobber" DependsOnTargets="_CoreClean">
   <!-- How to retrieve @(CompiledAssemblies) as if we were
        building @(Project) and retrieving the @(TargetOutputs) item group.
     -->
</Target>

我尝试了各种方法,包括创建自定义任务,在其中构建自定义项目文件,该文件导入我想要从中检索属性/项目的原始项目。但这并没有给我可靠的价值观。

有没有办法在不实际执行构建的情况下检索 MSBuild 项目的 TargetOutputs 项组?

I'm implementing an MSBuild framework to drive the building and deployment of many projects organized as a hierarchy.

<Target Name="_CoreBuild">
  <MSBuild Projects="@(Project)" Targets="Build" Properties="Configuration=$(Configuration)">
    <Output TaskParameter="TargetOutputs" ItemName="CompiledAssemblies" />
  </MSBuild>
</Target>

In order to implement proper Clean/Clobber logic, I would like to retrieve the list of files that would be compiled if a build were performed with the current options.

<Target Name="_CoreClobber" DependsOnTargets="_CoreClean">
   <!-- How to retrieve @(CompiledAssemblies) as if we were
        building @(Project) and retrieving the @(TargetOutputs) item group.
     -->
</Target>

I've tried various methods, including creating a custom task, in which I build a custom project file that imports the original project I want to retrieve the properties/items from. But that does not give me reliable values.

Is there a way to retrieve an MSBuild project's TargetOutputs item group without actually performing a build?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

国际总奸 2024-12-17 19:08:30

没关系。

我偶然发现以下类似问题,并认为我必须使用 GetTargetPath 目标,如下所示:

<Target Name="_CoreBuild">
  <MSBuild Projects="@(Project)" Targets="GetTargetPath" Properties="Configuration=$(Configuration)">
    <Output TaskParameter="TargetOutputs" ItemName="CompiledAssemblies" />
  </MSBuild>
</Target>

Never mind.

I stumbled upon the following similar question, and figured I had to use the GetTargetPath target, like so:

<Target Name="_CoreBuild">
  <MSBuild Projects="@(Project)" Targets="GetTargetPath" Properties="Configuration=$(Configuration)">
    <Output TaskParameter="TargetOutputs" ItemName="CompiledAssemblies" />
  </MSBuild>
</Target>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文