I have a build target I'm trying execute in MSBuild. The Target has some inputs and outputs I have put there to speed up the time in case of an intermediate build. The input files always exist (header files), on the other hand, the outputs don't always exist (XML files).
An intermediate build that possibly skips the task is quite desirable as it is quite costly in terms of performance.
Anyways, the inputs and outputs work great IF the outputs already exist. In that case MSBuild emits a very helpful message saying the target is skipped since all the files are up to date.
It's the case when the output directory and files don't exist (The very first time this task is run) that MSBuild fails with the following message:
Skipping target [targetname] because it has no outputs.
Adding Detailed verbosity tells me the reason is because the @(OutputXML) items are empty. Ok, so what now? It doesn't seem therefore that the whole concept of Intermediate Builds in MSBuild is very robust then.
My question is, how can I gain the benefit of an intermediate build and still have this target execute when there are no outputs? (I'm hoping I don't have to resort to writing my own task extension)
Here is the relevant portion of my build script:
<ItemGroup>
<Headers Include="..\**\*.h" />
<OutputXML Include="$(OutputDir)\*.xml" />
</ItemGroup>
<Target Name="Doxygen"
Inputs="@(Headers)"
Outputs="@(OutputXML)" >
<Exec ... />
</Target>
Note: I've been all over google, msdn, and this website trying to find an answer and so far have been unsuccessful. Though I have found very helpful information about MSBuild in general.
What about using a dummy output?
<ItemGroup>
<Headers Include="..\**\*.h" />
<OutputXML Include="$(OutputDir)\*.xml" />
</ItemGroup>
<ItemGroup Condition="'@(OutputXML)' == ''">
<OutputXML Include="$(OutputDir)\dummy.xml" />
</ItemGroup>
<Target Name="Doxygen"
Inputs="@(Headers)"
Outputs="@(OutputXML)" >
<Exec ... />
</Target>
When setting OutputDir to dummy.xml it isn't empty anymore, even if the file does not exist. The wildcard indicates that you are searching for any .xml and didn't find one, but naming one specific wouldn't do a search and therefor doesn't care if it exists or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With