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

在新建Setup Project

 

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

 

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

注意一点,Setup Project本身不提供卸载的功能。需要自己添加。
可以在Application Folder添加Uninstall.bat文件,内容是:
C:\Windows\system32\MsiExec.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;
            }
        }
    }

Setup Project 安装项目的更多相关文章

  1. 通过setup.py安装项目dependencies

    一.使用方法 安装命令   $ pip install  -e  <option> setup.py 二.具体介绍 pip intall -e 举例一个setup.py $ pip int ...

  2. VS2017、VS2019没有Setup安装项目(Visual Studio Installer)_解决方案

    前言: VS2010中有一个自带的安装部署项目,叫:Visual Studio Installer ,我们通常称为:setup项目,是一个用于自定义安装部署的项目方案.但是在VS2017,VS2019 ...

  3. vue入门之vue-cli安装项目

    第一步先安装nmp 在node.js的官网下载即可. 第二步 直接安装刚下载好的node.js即可,(这里建议不要修改node.js的安装路径),傻瓜式直接下一步即可 检测是否安装成功: 在cmd的控 ...

  4. C# winform程序怎么打包成安装项目(VS2010图解)

    作为研发人员,在本机上开发的winform.wpf或者控制台程序需要发给其他人测试时候,一般需要对其进行打包生成setup安装文件,根据网上查找的资料并结合自己打包成功,记录如下: 注:本程序是一个利 ...

  5. 【ctags/cscope/project安装使用】给神编辑器vim添加新的翅膀

    本文地址 分享提纲: 1.安装 2.使用cscope 3.使用project 1.安装 1.1)linux(yum下安装) yum -y install cscope 1.2)linux(unbunt ...

  6. (转)winform安装项目、安装包的制作、部署

    本文转载自:http://zhan.renren.com/cxymst?gid=3602888498037535727&from=post&checked=true 1,解决方案—添加 ...

  7. Visual Studio Installer打包安装项目VS2015

    使用VS2015的Visual Studio Installer打包安装项目,虽然整体操作很简单,但还是有几个特殊的点需要记一下,故写下此博客方便以后查阅 第一步,创建安装项目 如下: 里面最左侧的框 ...

  8. Visual Stdio 2015打包安装项目的方法(使用Visual Studio Installer)

    首先在官网下载VS2015的Visual Studio Installer 1.创建安装项目 里面最左侧的框框有三个文件夹 1.“应用程序文件夹”即"Application Folder&q ...

  9. C#ActiveX安装项目

    C#开发的ActiveX控件发布方式有三种: 制作客户端安装包,分发给客户机安装: 制作在线安装包,客户机联机安装: 使用html中object的codebase指向安装包地址. 以下为制作安装包: ...

随机推荐

  1. 【M21】利用重载技术避免隐式类型转换

    1.考虑UPint 的加法+,UPint a, b, result; 为了使result = a+10; result= 10+a; 都能通过编译,操作符重载如下: const UPint opera ...

  2. 为joomla加入下拉菜单的方法

    用 Joomla! 建站的大多数站长都须要在站点前台使用下拉菜单(dropdown menu),或者叫弹出菜单(slide menu),由于这样能够在有限的页面空间上公布很多其它的导航菜单,而且能够进 ...

  3. SSH框架之Struts(2)——Struts的执行流程之配置文件

    上篇我们大致了解了一下採用了Struts框架的web页面运行流程. 接下来的几篇我们通过Struts的源代码来学习一下Struts的内部原理. 当server启动的时候.server会依据配置文件初始 ...

  4. .net控件Control透明

    public partial class tspControl : UserControl { public tspControl() { InitializeComponent(); SetStyl ...

  5. MYSQL 分析表、检查表和优化表

    1. 对表进行优化 ( 优化表主要作用是消除删除或者更新造成的空间浪费) 2. 对表进行分析(分析关键字的分布, 分析并存储MyISAM和BDB表中键的分布) 3. 对表进行检查(检查表的错误,并且为 ...

  6. 小白日记6:kali渗透测试之被动信息收集(五)-Recon-ng

    Recon-ng Recon-NG是由python编写的一个开源的Web侦查(信息收集)框架.Recon-ng框架是一个全特性的工具,使用它可以自动的收集信息和网络侦查.其命令格式与Metasploi ...

  7. python打印详细的异常信息

    #!/usr/bin/env python #coding=utf-8 import traceback try: 1/0 except Exception, e: print e print tra ...

  8. Recovery启动流程(2)---UI界面

    转载请注明来源:cuixiaolei的技术博客 Recovery启动流程系列文章把recvoery目录下文件分成小块讲解,最后再以一条主线贯穿所有的内容.这篇文章主要讲解Recovery-UI的相关内 ...

  9. 对于android触摸事件模型的一些理解

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  10. 终于又可以用WLW了.

    前面有一段时间没有写博客,然后过完年想继续用WLW的时候,出现问题了. An unexpected error occurred while attempting to detect weblog s ...