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?
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>