安装盾自动化界面 - 始终覆盖



我正在尝试为我工作的公司自动创建安装包,并使用Installshield自动化界面创建MSI项目。到目前为止,我们所做的一件事(如果您可以相信,请手动(是在将文件导入 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 项目不支持此属性。您需要从自动化代码中删除调用该属性的行。

我在 2010 年的 flexera 社区论坛上发现了一个旧的论坛帖子,其中 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 年内没有解决这个问题

https://community.flexerasoftware.com/showthread.php?194448-installshield-2009-automation-File-property-quot-Always-overwrite-quot

无论如何,以上似乎有效

最新更新