Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way to add a file to XYZ.csproj.FileListAbsolute.txt?

Tags:

msbuild

My build code creates one extra file in the bin folder. I want it cleaned when the solution is cleaned. However, the name of the file is determined by the AssemblyName property of the project. So, if this property is changed (rare, but happens), then the only way to have the old file cleaned is if it is written in XYZ.csproj.FileListAbsolute.txt.

Do I just write to XYZ.csproj.FileListAbsolute.txt whenever I create my file or is there a better way to do it?

like image 812
mark Avatar asked Jan 01 '26 21:01

mark


1 Answers

OK, I found it.

Just add the file to the FileWrites item list, like this:

<ItemGroup>
  <FileWrites Include="$(SomeFileYouWantCleanedUpOnClean)"/>
</ItemGroup>

In my code this is part of a target than runs BeforeBuild and BeforeRebuild, but it may as well work when defined in the global scope.

like image 140
mark Avatar answered Jan 03 '26 10:01

mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!