如何以编程方式更改产品代码 [英] How to change product code programmatically
问题描述
我已经创建了bat文件以进行自动构建.它是我产品的安装程序.但是问题在于,在运行自动构建脚本之前,我必须从install shield手动更改产品代码.那么,有什么办法可以自动更改产品代码?因为除产品代码外,一切都是自动的.
I have created bat file for automatic build. It's create installer of my product. But problem is that before run automatic build script I have to change product code manually from install shield. So, is there any way to change product code automatically ? because everything is automatic except product code.
推荐答案
正如Phil所说,您可以通过用于Installshield的COM自动化界面来做到这一点,但是这里还介绍了其他方法: Installshield构建自动化 .
As Phil says you can do this via the COM automation interface for Installshield, but there are also other ways as explained here: Installshield Build Automation.
本质上:
-
上面的链接显示了一个有关如何使用独立生成可执行文件 ISCmdBld.exe 的小示例-您可能已经在使用它.
The link above shows a small sample of how to use the standalone build executable ISCmdBld.exe - which you might already be using.
- 类似:
"[PATHHERE]ISCmdBld.exe" -p "MyInstaller.ism" -r SingleImage -y "1.0.0.13" -z ProductCode=%guid%
. - 请检查上面的链接-我从未使用过ISCmdBld.exe来选择COM自动化.
The linked answer also explains how to use msbuild, read Urman's answer.
最后,您可以使用 COM自动化界面和VBScript(或Javascript?),并且我在下面添加了一个小示例来说明其工作原理.
Finally you can use the COM automation interface and a VBScript (or Javascript?), and I have added a small sample below for how this can work.
我没有Installshield 2013,但是这是一个非常粗略的草图,其中介绍了如何使用VBScript通过 COM自动化来自动化最新版本2016:/p>
I don't have Installshield 2013 available, but here is a very rough sketch of how you can automate the latest version 2016 via COM automation using a VBScript:
' On Error Resume Next
Set isproject = CreateObject("ISWiAuto23.ISWiProject")
isproject.OpenProject "C:\InstallShield 2016 Projects\TestProject.ism", False
Set isproductconfig = isproject.AddProductConfig("MyNewProduct_1.0.16")
isproductconfig.ProductName = "MyNewProduct_1.0.16"
isproductconfig.ProductVersion = "1.0.16"
isproductconfig.ProductCode = isproject.GenerateGUID
' lots of properties to set, the above should normally suffice I think...
Set isrelease = isproductconfig.AddRelease("MyNewRelease_1.0.16")
isrelease.Compressed = True
isrelease.SetupEXE = True
' lots of properties to set...
' Save and build project
isproject.SaveProject ' For some reason the project won't save properly after it is built
isrelease.Build
isproject.SaveProject
' Report error status
WScript.Echo "Number of Build Errors: " & CStr(isrelease.BuildErrorCount)
WScript.Echo "Number of Build Warnings: " & CStr(isrelease.BuildWarningCount)
isproject.CloseProject
这个脚本没有经过彻底的测试,而且很奇怪,除非您在触发构建之前进行了保存,否则不会保存新产品的配置和发行版.可能是我混淆了一些简单的事情-或可能是该工具中的错误(这不是第一个).
This script wasn't tested that thoroughly, and weirdly, the new product configuration and release are not saved unless you save before triggering the build. It might be something simple I have mixed up - or it might be a bug in the tool (it wouldn't be the first one).
按原样进行操作,希望它可以帮助您解决 wilburys (错误).我认为如果将ISWiAuto23.ISWiProject
更改为IswiAuto20.ISWiProject
以匹配Installshield 2013 COM服务器版本,它可能会运行.
Take it for what it is, let's hope it gets you going to work out the wilburys on your own (bugs). I think it might run if you change ISWiAuto23.ISWiProject
to IswiAuto20.ISWiProject
to match the Installshield 2013 COM server version.
至关重要的是,您必须从32-bit CScript.exe / WScript.exe
运行VBScript(不要问我为什么).只需在台式机上放置C:\Windows\SysWOW64\cscript.exe
的快捷方式进行测试,然后将脚本拖放到其中即可,或者更好的是,打开命令提示符并转到C:\Windows\SysWOW64
(不管您相信与否,这是32位文件夹-和 System32文件夹为64位(!)-仅在Windows中!),然后键入cscript.exe [FullPathToVBScript]
.显然,请记住在运行脚本之前在Installshield GUI中关闭ISM文件.
Crucially, you must run the VBScript from a 32-bit CScript.exe / WScript.exe
(don't ask me why). Just put a shortcut to C:\Windows\SysWOW64\cscript.exe
on your desktop for testing, and drag and drop your script onto it, or better yet, open a command prompt and go to C:\Windows\SysWOW64
(believe it or not this is the 32-bit folder - and the System32 folder is 64 bit (!) - only in Windows!) and then type cscript.exe [FullPathToVBScript]
. Obviously remember to close your ISM file in the Installshield GUI before running the script.
我喜欢这样一个事实,您可以将新版本和产品配置保存在* .ism文件中,这样就可以记录已编译的版本.我不确定ISCmdBld.exe会做什么.
I like the fact that you can save the new release and product config inside the *.ism file so you have a record of compiled releases. I am not sure what ISCmdBld.exe does.
这篇关于如何以编程方式更改产品代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!