I would use a goal to achieve this goal. In particular, I would suggest redefining the BeforeBuild target. There are several ways to do this, but the easiest is to modify your .vcxproj IMHO file.
At the bottom of the project file (you can edit it by right-clicking on your project in Visual Studio → Unload Project, then right-clicking again and choosing to edit this project), you should see the line <Import ... , Add a target after this line, something like this:
<Target Name="BeforeBuild" Condition="Exists('$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config')"> <Delete Files="$(ProjectDir)\obj\Debug\Package\PackageTmp\web.config" /> </Target>
See How to: Extend the Visual Studio build process for more information on redefining goals before and after.
source share