开发者

one-click deploy - how do I ensure the sqlite database file only gets copied if it doesn't already exist?

开发者 https://www.devze.com 2022-12-22 00:04 出处:网络
Background - I\'m starting to use click-once deploy for a WinForms application that has a sqlite database file, which holds the blank database structu开发者_如何学Gore ready to go.

Background - I'm starting to use click-once deploy for a WinForms application that has a sqlite database file, which holds the blank database structu开发者_如何学Gore ready to go.

Question - How do I set things up so that the click-once deploy (via Publish, in VS2008) will ensure that when the user downloads it will:

  • a) If does not already exist then COPY the file in, else
  • b) Do NOT copy the file in, BUT check to see whehter there is an upgrade script that should be run

Thanks


This does not answer your question directly, but I thought the information would be of use to you in planning how you want to handle your situation. Read here (particularly the section titled "Data Directory and Application Versions") for a description of how ClickOnce handles files in the data directory. Also, to treat your database as a data file, make sure your database file is labeled as a data file (Inside VS.Net - Go to Project Properties -> Project -> Application Files - make sure "Publish Status" is "Data File"). Below I have pasted the section in that article I am referring to. One thing you may want to explore is using the IsFirstRun property - then checking to see if the database exists, if not create at runtime, if needs update then update, etc.... (using this method, you may want to create the database "outside" of the clickonce data directory or create a new database at runtime inside of the data directory that does not exist in the deployment so that you can control how the database is effected by updates).

"Data Directory and Application Versions

Each version of an application has its own Data Directory, which is isolated from other versions. ClickOnce creates this directory regardless of whether any data files are included in the deployment so that the application has a location to create new data files at run time. When a new version of an application is installed, ClickOnce will copy all the existing data files from the previous version's Data Directory into the new version's Data Directory—whether they were included in the original deployment or created by the application.

ClickOnce will replace the older version of the file with the newer version of the server if a data file has a different hash value in the old version of the application as in the new version. Also, if the earlier version of the application created a new file that has the same name as a file included in the new version's deployment, ClickOnce will overwrite the old version's file with the new file. In both cases, the old files will be included in a subdirectory inside the data directory named .pre, so that the application can still access the old data for migration purposes.

If you need finer-grained migration of data, you can use the ClickOnce Deployment API to perform custom migration from the old Data Directory to the new Data Directory. You will have to test for an available download by using IsFirstRun, download the update using Update or UpdateAsync, and do any custom data migration work in your own after the update is finished."


Perhaps "migratordotnet" would be a good fit to my question?

Found it at: http://code.google.com/p/migratordotnet/wiki/GettingStarted

0

精彩评论

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