How to retrieve @(TargetOutputs) without performing a build

混江龙づ霸主 提交于 2019-12-04 01:30:21

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/7823975/how-to-retrieve-targetoutputs-without-performing-a-build

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