我试图为我工作的公司自动创建安装包,并使用Installshield Automation创建MSI项目。到目前为止,我们所做的事情之一(如果您可以相信的话,手动的话)是在将文件导入安装屏蔽并将其设置为“始终覆盖”一个文件夹的基础上,然后遍历我们想要释放的所有文件,因为您似乎不能在父文件夹上递归地执行这些操作。当在安装屏蔽GUI上创建基本的MSI时,它允许您这样做,但是当通过COM对象创建MSI时,这个选项似乎只对InstallScript可用,而我不能用它来创建MSI。
任何我的代码看起来都是这样的
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项目不支持此属性。您需要从自动化代码中删除调用该属性的行。
发布于 2018-09-20 07:48:55
我在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://stackoverflow.com/questions/52404845
复制相似问题