I’m currently writing an msbuild script and having issues deleting *.vshost.exe.
Before I build and deploy my project I run the Clean target as well as this target.
<Target Name="CleanLogs">
<ItemGroup>
<FilesToDelete Include="$(OutputPath)\*.*" />
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
</Target>
The CleanLogs target is to pick up log files we generate that the default Clean target won’t pick up. More often than not there seems to be a lock on *.vshost.exe.
How can I force delete this file?
You can’t delete it, it is the Visual Studio hosting process and it is always executing while you have the project opened. The .exe for an executing process can’t be deleted.
Make it more selective, like
*.log. Also give some consideration to how this is going to work on your user’s machine, you cannot create files in ac:\program filessubdirectory on Vista and up. These log files belong in an appdata or documents folder.