简体   繁体   English

需要一种方法将一个属性添加到VS2010中安装项目的msi属性表中

[英]Need a way to add one property to the msi properties table in setup project in VS2010

I've been using Orca to manually add property "REINSTALLMODE" value "amus" into the msi property table every time I build it. 每次我构建它时,我一直在使用Orca手动将属性“REINSTALLMODE”值“amus”添加到msi属性表中。

I'm sick of this. 我厌倦了这一点。 I looked into Wix but so far I don't think its worth the hassle to learn it/switch to it just yet, even though it will solve this problem. 我调查了Wix,但到目前为止,我认为它不值得学习它的麻烦/切换到它,即使它将解决这个问题。 Is there a way I can automatically insert this one property into the msi after the build is complete? 有没有办法在构建完成后自动将这一个属性插入到msi中? Preferably, it will use only vanilla visual studio 2010 and not depend on third party programs or system environment variables. 优选地,它将仅使用vanilla visual studio 2010而不依赖于第三方程序或系统环境变量。

Any thoughts? 有什么想法吗?

Thanks, 谢谢,

Isaac 艾萨克

use a vbscript 使用vbscript

change an existing property 更改现有财产

set o_installer = CreateObject("WindowsInstaller.Installer")
set o_database = o_Installer.OpenDatabase("path_to_your_msi", 1)
s_SQL = "SELECT Property, Value FROM Property Where Property = 'ReinstallMode'"
Set o_MSIView = o_DataBase.OpenView(s_SQL)
o_MSIView.Execute
Set o_MSIRecord = o_MSIView.Fetch
o_MSIRecord.StringData(2) = "amus"
o_MSIView.Modify 2, o_MSIRecord
o_DataBase.Commit

add an new property 添加新属性

set o_installer = CreateObject("WindowsInstaller.Installer")
set o_database = o_Installer.OpenDatabase("path_to_your_msi", 1)
s_SQL = "INSERT INTO Property (Property, Value) Values( 'ReinstallMode', 'amus')"
Set o_MSIView = o_DataBase.OpenView( s_SQL)
o_MSIView.Execute
o_DataBase.Commit

Another option is to include the version number in the application's install folder. 另一个选项是在应用程序的安装文件夹中包含版本号。
Set Application folder's default location to something like: 将Application文件夹的默认位置设置为:
[ProgramFilesFolder]\\[ProductName]\\[ProductVersion] [ProgramFilesFolder] \\ [产品名称] \\ [的ProductVersion]
Also set the Setup project's 'RemovePreviousVersions' property to true. 还将Setup项目的“RemovePreviousVersions”属性设置为true。
This should delete the old version's folder and create a fresh folder for the new version. 这应删除旧版本的文件夹,并为新版本创建一个新文件夹。
Remember to change the Setup project's version property every time you do a new release. 每次执行新版本时,请记住更改安装项目的版本属性。

My honest thoughts? 我诚实的想法? You are starting down the road of "VDPROJ is fine except I also need it to do [x]." 你开始沿着“VDPROJ很好,除了我还需要它做[x]。” You'll find a way to hack it and then you'll repeat. 你会找到一种方法来破解它,然后你会重复。 Before you know it you'll have a frankenstein solution that is doing all kinds of wierd things to your MSI because the tool doesn't expose it or worse implements it wrong. 在您了解它之前,您将拥有一个frankenstein解决方案,它正在为您的MSI做各种奇怪的事情,因为该工具不会暴露它,或者更糟糕的是它实现了错误。 I really suggest going to InstallShield 2010LE/Pro or WiX. 我真的建议去InstallShield 2010LE / Pro或WiX。

However, if all you want to do is change REINSTALLMODE from omus to amus, I reccomend using Orca to create a transform one time and then in a post build step apply the transform to your built MSI. 但是,如果您要做的只是将REINSTALLMODE从omus更改为amus,我建议使用Orca创建一次转换,然后在post build步骤中将转换应用于构建的MSI。

cscript WiUseXfm.vbs [path to original database][path to transform file][options]

Apply a Transform 应用变换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM