Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When compiling/debugging, is VS supposed to delete existing files in the bin\debug area?

Tags:

Q1 - When doing a compile/debug is VS supposed to delete existing files in the bin\debug area? (for VS2008)

if no then can I ask please:

Q2 - My winforms checks for existance of a sqlite.db3 file and creates it if it needs to (programmatically). If the behavior I wanted was that each Compile/Debug I do is for the target Debug area to be clear, so that the program would exercise the code that builds the database file, how would I organise this?

thanks

like image 277
Greg Avatar asked Mar 15 '10 02:03

Greg


2 Answers

Simply add a PreBuild event.

Edited to add:

Well... looks like someone wants it all chewed up and ready to swallow. Okie dokie!

  1. Right click the Project and select properties
  2. Navigate to

    a. Compile tab and click on the Build Events button if a VB project

    b. Build Events tab if it's a C# project

  3. in the pre-build event command line type:

    IF EXIST "$(TargetDir)\sqlite.db3" DEL "$(TargetDir)\sqlite.db3"

That should do it.

Next time, fiddle a little longer...

like image 127
Paulo Santos Avatar answered Sep 28 '22 07:09

Paulo Santos


"Clean" will only delete files that Visual Studio is explicitly copying to the target directory (your executable, dependent dlls, and those files marked with appropriate "Copy to Output Directory" values).

You might create a pre-build or post-build task to delete the file in question. Something like del $(TargetDir)\sqlite.db3. See the "Build Events" tab in your project properties for these events.

like image 38
Michael Petrotta Avatar answered Sep 28 '22 07:09

Michael Petrotta