C
C#11mo ago
n8ta

How to run a target when any of a set of input files has changed?

I'm trying to build a large project that msbuild does not understand via a <Target> with the inputs parameter as a list of all source files in that project and outputs as the single file the build produces. However, even when I change a file in the Inputs of the <Target> the target is not re-run. There is not a 1-1 mapping between inputs and outputs.
<Target Name="CustomJsBuildLocal" Inputs="@(JsInputFiles)" Outputs="@(JSOutputFiles)">
<Message Importance="High" Text="Building" />
<Exec ConsoleToMsBuild="true" Command="some kinda slow command based on input fules" WorkingDirectory="$(BuildFolder)">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
</Target>
<Target Name="CustomJsBuildLocal" Inputs="@(JsInputFiles)" Outputs="@(JSOutputFiles)">
<Message Importance="High" Text="Building" />
<Exec ConsoleToMsBuild="true" Command="some kinda slow command based on input fules" WorkingDirectory="$(BuildFolder)">
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
</Target>
8 Replies
mtreit
mtreit11mo ago
I added you to an email thread with my msbuild expert.
n8ta
n8taOP11mo ago
Hey Mike thanks received! I've messed with it for a few hours and at this point I'm ready to bail and run a node script to it (: Could not find any way to debug why a target did or did not run
mtreit
mtreit11mo ago
msbuild /bl
n8ta
n8taOP11mo ago
binlog?
mtreit
mtreit11mo ago
Then open the .binlog it produces with the binary log viewer It should say why or why not each target ran. Just search for your target name
n8ta
n8taOP11mo ago
Got it testing thx @mtreit doesn't show up at all in the output. The only difference between this target and those that show up is this one doesn't have a BeforeTarget / AfterTarget property If I change that I see it and some debug info on why it didn't run !
mtreit
mtreit11mo ago
You might want to put it in the DefaultTargets for the project?
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;CustomJsBuildLocal">
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Build;CustomJsBuildLocal">
Or use AfterTargets. It doesn't run all target by default I don't think.
n8ta
n8taOP11mo ago
I put it in beforebuild for now beforeTargets=beforeBuild This is the only thing being built in this .proj I'll try default

Did you find this page helpful?