zoukankan      html  css  js  c++  java
  • Setup Project 安装项目

    从vs2012起,微软已经不支持setup project了。以此纪念一下setup project。
     

    在新建Setup Project

     

    增加安装内容,通常是直接Oupput一个项目,或者直接添加exe,dll

     

    File System中,可以选择程序安装的目录。

    注意一点,Setup Project本身不提供卸载的功能。需要自己添加。
    可以在Application Folder添加Uninstall.bat文件,内容是:
    C:Windowssystem32MsiExec.exe /I{ProduceCode}
    ProduceCode需替换成Setup Project属性中的ProduceCode
     
    还可以在User' Programs Menu中添加指向Uninstall.bat的快捷链接
     
    这里提到可以调用系统自带的 msiexec.ext 进行卸载。但是经网友测试得出如下结论:
    Awesome, works very well for me on WinXP/Vista & Win7. Worth noting that according to the article linked to, if you use a version of msiexec.exe HIGHER than the target platform there are issues. This is not an issue for me as I'm still intentionally using XP for building - but obviously if you want an installer built on Vista to run on XP that will be an issue. 
     
    也有网友提出如下解决方案
    Regarding the problem that arises when building the Installer under Vista/7, and the installer tries to overwrite msiexec on older, XP machines; this can be corrected by creating an empty .txt file, and renaming it to "msiexec.exe." Include that file in your installer, rather than the actual System32 version. Since the empty, fake file has no version information, it will not try to overwrite the XP msiexec
     
    但我试过,是行不通的。>_<
     
    所以,还是乖乖用回Uninstall.bat实现卸载。
     

    增加User Interface

     
    在这里可以增加自定义的安装界面,但是只能用它定义好的样式,不能内嵌页面
     

    增加Custom Action

     
    这里可以添加自定义的,针对安装期间生命周期的事件。我这里是在dll中定义了一个InstallHelper的类,在安装的过程中写一个xml文件
        [RunInstaller( true )]
         public class InstallHelper : Installer
        {
             public override void Install(System.Collections.IDictionary stateSaver)
            {
                 base .Install(stateSaver);
     
                 try
                {
     
                     string brandType = string .IsNullOrEmpty(Context.Parameters[ "BrandType" ]) ? "HuaShi" : Context.Parameters[ "BrandType" ];
                  
                     string assemblypath = Context.Parameters[ "assemblypath" ];
     
                     string pathName = Path.Combine(Path.GetDirectoryName(assemblypath), brandType + ".xml" );
     
                     if (File.Exists(pathName))
                    {
                        File.Delete(pathName);
                    }
     
                     using (Stream st = File.Open(pathName, FileMode.OpenOrCreate))
                    {
                        var writer = XmlWriter.Create(st);
                        writer.WriteStartDocument();
     
                        writer.WriteStartElement( "Info" );
                        writer.WriteElementString( "Seed" , System.Guid.NewGuid().ToString());
                        writer.WriteElementString( "Brand" , brandType);
                        writer.WriteEndElement();
                        writer.Close();
                    }
                }
                 catch (FormatException e)
                {
                     string s = e.Message;
                }
            }
        }




  • 相关阅读:
    Java网络技术-待续
    Java输入输出技术
    Java数据库技术
    Java安全技术
    Java异常、事件、多线程
    网站产品设计
    C#-委派和事件
    Quartz 触发器(SimpleTrigger&CronTrigger )配置说明 & cronExpression表达式 转
    weblogic出现response already committed(转)
    Weblogic二种修改端口的方法(转)
  • 原文地址:https://www.cnblogs.com/lostpaddle/p/3198502.html
Copyright © 2011-2022 走看看