As part of one of my projects, there are "BeforeBuild" tasks that ultimately generate some files. In particular, it compiles a small static class (included as "do not compile" in the project) into it's own executable and then executes it, passing in an external input file outputting a new generated class to be included in the project.
I programmed it to put the intermediate files in the projects $(OutDir), but found that on "Rebuild" (and ultimately "Clean"), these files aren't picked up. After some thought, I realized that the final, generated class which is placed right in $(ProjectDir) should probably be deleted on "Clean" too.
Some investigation into Microsoft.Common.targets revealed that there was some "master list" from the intermediate path (obj\build\assembly.FileListAbsolute.txt) that was queried for the files to delete.
Is there some standard method of adding my new files to this list in MSBuild to have them cleaned up, or would this sort of thing fit better in a "BeforeClean" (or "AfterClean") target override?
Cleaning up specific projects: msbuild MyProjectFile1 /t:Clean msbuild MyProjectFile2 /t:Clean ... This has to be repeated for all projects you need to clean, because MSBuild only accepts single project on command line.
For a multi-project solution, "rebuild solution" does a "clean" followed by a "build" for each project (possibly in parallel). Whereas a "clean solution" followed by a "build solution" first cleans all projects (possibly in parallel) and then builds all projects (possibly in parallel).
To build, rebuild, or clean an entire solution Choose Build All to compile the files and components within the project that have changed since the most recent build. Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files.
See Extending the Clean Process for details of the FileWrites mechanism (which is the system writing the FileListAbsolute.txt
you're seeing) in this MSBuild article by Hashimi. And get the book right now if you're going to spend more than 2 hours writing build scripts in the next year.
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