Replace .SDF database file through .msi upgrade proceed
Since there's no File Version attribute for the SDF database file for the Existing File replacement policy, but sometimes we really need to replace the SDF file(change the init data, or others things makes you need to replace the database file).
Then we just can edit the .MSI file File table to add the File Version number for the .SDF file, then it can use the Existing File replacement policy:

Then we just need to update the version number once we need to replace the .sdf database file for our product.


Then we can configure the Setup project Post-build Event according to this command to update the msi file:

Cscript WiRunSQL.vbs Setup2.msi "UPDATE `File` SET `File`.`Version`='' WHERE `File`.`FileName` = 'DATABA~1.SDF|Database1.sdf'"!723&parid=BB789F72272D4858!721

[C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiRunSQL.vbs]

I have not found any MSDN document mentioned this way to help our work, this is just based on my experiences and test cases, so please consider carefully before use this way in your product deployment.

ref my Google Blog:

posted @ 2012-02-06 15:34  Mike Dos Zhang  阅读(233)  评论(0编辑  收藏  举报