The 10,000th Why won't my MSBuild task run post
So, I'm trying to get a custom task to work in Visual Studio. I can get this to work with a custom build tool, but that's not viable because (for really stupid reason) you cannot indicate a build target for a custom build tool that I can see. There's only a project level build target and all custom steps and tools use the same one. So if you also need custom build steps on other targets that's not workable.
I'm on 2019. Here is what I have (one of an ~infinite set of variations I've tried)
<Target Name="SpidlGen" BeforeTargets="BeforeBuild"
Inputs="$(ProjectDir)SpidlGen_Gen.Spidl"
Outputs="$(ProjectDir)SpidlGen_Gen.cpp;$(ProjectDir)SpidlGen_Gen.h">
<Message Text="Spidl File Generation" Importance="High"/>
<Exec Command="$(SolutionDir)Tools\Spidl.exe $(ProjectDir)SpidlGen_Gen.Spidl $(ProjectDir)SpidlGen_Gen.cpp $(ProjectDir)SpidlGen_Gen.h"/>
</Target>
<ItemGroup>
<None Include="SpidlGen_Gen.spidl"/>
</ItemGroup>
I have the inputs and outputs correct. I have a high priority message so I can see if it's run. It never runs, ever. I can change the source or delete the output files altogether and it never gets invoked.
Am I missing something obvious? I looked through all the log files and there's nothing there that at all indicates it even tried or evaluated this target.
It really just shouldn't be this hard to add the invocation of a tool to the build process. I've been at this now for a full work day and have achieved nothing but a real dislike of this tool.
Posted May 18, 2020, 3:09 PM UTC · edited
OK, after more experimentation driving it temporarily from the command line, where I can see what targets are being invoked, I see more of what is going on.
This is a code generator. So it's spitting out a cpp and h file. If those files are deleted, the target isn't being invoked so the file don't get generated. It just goes straight to trying to compile and fails because the files aren't there.
If the files do exist, I can get the generator to run, but the check to see if anything needs to be compiled is clearly being done before that, so it doesn't actually try to rebuild the files until the next build invocation.
So basically what I'm trying to do is:
I just cannot seem to get that these things to work. And, inevitably as I try to get these to work, I break the working scenarios, because this system is just so twitchy.