从< MSBuild>返回ReferenceCopyLocalPaths.任务 [英] Return the ReferenceCopyLocalPaths from <MSBuild> task

查看:98
本文介绍了从< MSBuild>返回ReferenceCopyLocalPaths.任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个<ProjectReferences>的自定义MSBuild项目文件. 我正在调用<MSBuild Projects="@(ProjectReference)" Targets="Build">任务,并且可以使用<Output TaskParameter="TargetOutputs" ItemName="OutputAssemblies" />元素获取所有已构建的程序集,然后将@(OutputAssemblies)复制到目标目录.

I have custom MSBuild project file with few <ProjectReferences>. I'm calling the <MSBuild Projects="@(ProjectReference)" Targets="Build"> task and I can get all the built assemblies using the <Output TaskParameter="TargetOutputs" ItemName="OutputAssemblies" /> element and I'm copying @(OutputAssemblies) to destination directory.

我希望能够从ResolveAssemblyReferences目标获取@(ReferenceCopyLocalPaths)项目属性,但我不知道如何输出此属性.

I want to able to get the @(ReferenceCopyLocalPaths) item property from the ResolveAssemblyReferences target but I can't figure out how to output this property.

<Target Name="BuildDocumentationForReferencedProjects">
  <MSBuild
    Projects="@(ProjectReference)"
    Targets="Build"
    BuildInParallel="true"
    Properties="DocumentationFile=$(DllDir)\%(FileName).xml"
  >
    <Output TaskParameter="TargetOutputs" ItemName="OutputAssemblies" />
  </MSBuild>

  <Copy SourceFiles="@(OutputAssemblies)" DestinationFolder="$(DllDir)" />
</Target>

推荐答案

将以下自定义目标添加到您的项目文件中,或添加到所有您想通过这种方式获得此行为的项目导入的文件中.

Add the following custom target to your project file, or to a file imported by all projects you want to get this behavior with...

  <Target Name="MyResolveReferences"
    DependsOnTargets="ResolveReferences"
    Returns="@(ReferenceCopyLocalPaths)">
  </Target>

然后,您可以直接调用此目标并捕获您感兴趣的项目数组,因为此临时目标将其声明为其返回"值,

Then, you can call this target directly and capture the item array you are interested in, since this transitory target declares it as its "Returns" value,

  <Target Name="BuildDocumentationForReferencedProjects">
   <MSBuild
     Projects="@(ProjectReference)"
     Targets="MyResolveReferences"
     ...
     >
     <Output
        TaskParameter="TargetOutputs"
        ItemName="MyReferenceCopyLocalPaths"
        />
   </MSBuild>
   <Message Text="Paths = '@(MyReferenceCopyLocalPaths)'" />
  </Target>

除了@(ReferenceCopyLocalPaths)以外,还有许多其他有趣的项目数组,只需在声明为对ResolveAssemblyReferences目标中的ResolveAssemblyReference任务的调用的所有Outputs中查看Microsoft.Common.targets. 〜1400行).

In addition to @(ReferenceCopyLocalPaths) there are a number of other item arrays that might be interesting, just look in Microsoft.Common.targets at all the Outputs declared for the call to the ResolveAssemblyReference task in the ResolveAssemblyReferences target (mine is ~line 1400).

这篇关于从&lt; MSBuild&gt;返回ReferenceCopyLocalPaths.任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆