从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. C#不错的扩展工具类

    FSLibExtension.NET https://github.com/iccfish/FSLib.Extension WebEssentials2013 https://github.com/i ...

  2. cocos2dx 3.0 触摸机制

    在cocos2dx 3.0版本号中,废弃了以往2.x版本号的写法,我们先来看一下Layer.h中的一段代码 /* Callback function should not be deprecated, ...

  3. C++ 预编译头文件

    1.解决什么问题? C++ 编译器是单独,分别编译的,每个cpp文件,进行预编译(也就是对#include,define 等进行文本替换),生成编译单元.编译单元是一个自包含文件,C++编译器对编译单 ...

  4. Codeforces Round #330 (Div. 2)D. Max and Bike 二分 物理

    D. Max and Bike Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/595/probl ...

  5. Codeforces Gym 100342E Problem E. Minima 暴力

    Problem E. MinimaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attac ...

  6. delphi 05 图片和超链接

    超链接 /取消超链接 插入/取消 书签 插入图片 粘贴图上CTRL+v 截图 插入表情GIF WEB背景色 WEB背景图片      WebBrowser1.OleObject.document.ge ...

  7. centos6.x已经安装的系统添加图形界面

    yum groupinstall "X Window System" yum groupinstall GNOME Desktop Environment

  8. memset用法详解(转)

    问题描述: int * cow = new int[n+1]; memset(cow,0,(n+1)*4); 将N+1个元素置成0,为什么不行 memset是对一个字节的int4个字节,因此*4 但是 ...

  9. ios开发——实用技术篇OC篇&获取设备唯一标识

    获取设备唯一标识 WWDC 2013已经闭幕,IOS7 Beta随即发布,界面之难看无以言表...,简直就是山寨Android. 更让IOS程序猿悲催的是,设备唯一标识的MAC Address在IOS ...

  10. 更新mac自带的python

    mac lion自带的python是2.7版本的,有点儿低,要使用一些应用的时候还需要3.3以上的,这时可以用以下的方法更新mac自带的python. 先去python的官网下载最新的python,并 ...