Return the ReferenceCopyLocalPaths from <MSBuild> task

大兔子大兔子 提交于 2019-12-06 16:39:41

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>

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).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!