首页 > 解决方案 > 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 项目不支持此属性。您需要从自动化代码中删除调用该属性的行。

标签: c#automationcomreleaseinstallshield

解决方案


我在 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 年以来还没有解决这个问题

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

无论如何,以上似乎工作


推荐阅读