开发者

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

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 开发者_Python百科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


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...


"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.


There are events you can run before, after build for each project. So, pick the first/last project that builds depending on whether the action should happen before build or after build (enforce it by making it depend on every other project) and add some batch scripting to perform what you need. MSBuild tasks are great for this as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜