c# - Installshield 自动化界面 - 始终覆盖
问题描述
我正在尝试为我工作的公司自动创建安装包,并且正在使用 Installshield 自动化接口创建一个 MSI 项目。到目前为止,我们已经完成的一件事(如果您相信的话,可以手动执行)是在将它们导入 installshield 并将它们设置为“始终覆盖”之后逐个文件夹地检查我们想要发布的所有文件,因为它似乎您不能在父文件夹上递归地执行此操作。在 installshield GUI 上创建基本 MSI 时,它允许您执行此操作,但是当通过 COM 对象创建 MSI 时,此选项似乎仅适用于我无法制作 MSI 的 InstallScript。
我的代码看起来像这样的任何人
static void AddFiles(string[] aFiles, ISWiAuto24.ISWiProject oISProj, string sProjName, string ePackName)
{
oISProj.OpenProject(sProjName, false);
string installdirectory = "[ProgramFilesFolder]" + ePackName;
oISProj.INSTALLDIR = installdirectory;
Console.WriteLine("Adding ePack files");
for (int i = 0; i < aFiles.Length;i++ )
{
Console.WriteLine(aFiles[i]);
ISWiComponent NewComponent = oISProj.AddComponent("Component_"+i);
string string_PathToFile = aFiles[i].Substring(0,aFiles[i].LastIndexOf("\\"));
string string_RelativeToInstallDir = string_PathToFile.Substring(aFiles[i].LastIndexOf(ePackName) + ePackName.Length);
NewComponent.Destination = installdirectory+string_RelativeToInstallDir ;
NewComponent.AddFile(aFiles[i]);
/*----------------------------Fails Here--------------------------------------*/
NewComponent.OverwriteMainOptions=0;
/*----------------------------------------------------------------------------*/
}
oISProj.SaveProject();
oISProj.CloseProject();
Console.WriteLine("Done");
}
static voidMain(string[] args){
ISWiAuto24.ISWiProject oISProj = new ISWiAuto24.ISWiProject();
string ePackName = "ThisMonthsBundle"
string[] aFiles = new[] {@"c:/Foo/Roo/Goo/"+ePackName+"/File0",@"c:/Foo/Roo/Goo/"+ePackName+"/File1",@"c:/Foo/Roo/Goo/"+ePackName+"/File2",@"c:/Foo/Roo/Goo/File3"}
string sProjName = "C:/Foo/Bar.ism"
oISProj.CreateProject(sProjName, ISWiProjectType.eptMsi);
AddFiles(aFiles,oISProj,sProjName);
}
有谁知道解决这个问题的方法?
错误是:未处理 COM 异常 - 基本 MSI 项目不支持此属性。您需要从自动化代码中删除调用该属性的行。
解决方案
我在 flexera 社区论坛上发现了 2010 年的旧论坛帖子,其中 flexera 开发人员回复用户说可以这样做:
ISWiComponent NewComponent = oISProj.AddComponent("Component_1");
NewComponent.Destination = "[ProgramFilesFolder]" + "ProgramName";
NewComponent.AddFile("c:\File1");
ISWiFiles Files = NewComponent.ISWiFiles;
foreach (ISWiFile File in Files)
{
File.OverrideSystemVersion = true;
File.Version = "65535.0.0.0";
}
有问题的开发人员认识到需要自动化接口来支持 ISWiFile.AlwaysOverwrite 属性,并为此提出了工作指令。我想他们在 8 年以来还没有解决这个问题
无论如何,以上似乎工作
推荐阅读
- javascript - 如何解决 2 个冲突的 JavaScript 文件?
- python - 使用 Python 和 Pandas 根据 Dataframe 内容重命名文件
- javascript - 如果在禁用日期之前选择,如何禁用禁用日期之后的日期?
- sql - 如何计算每列中有多少个空值?
- docker - 为什么 docker restart 识别 docker-compose.yml 文件中的修改
- html - 了解如何将 CGI 编程与 C 和 HTML 结合使用
- linux - 获取可以提供给 AWS 安全的网站的 IP 地址
- javascript - 如何停止计数器动画?
- python - Pandas 列表中的多个交叉点
- javascript - 如何从以下代码中读取 data-product_id