从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. eclipse/MyEclipse 日期格式、注释日期格式、时区问题[转]

    http://www.cnblogs.com/hoojo/archive/2011/03/21/1990070.html 在eclipse/MyEclipse中,如果你的注释或是运行System.ou ...

  2. Arduino 4X3键盘 AD模拟分量实现

    //读分量测试 ---------------- ; //模拟口0 ; // 取得键AD模拟分量 void setup() { //通信波特率 Serial.begin(); } void loop( ...

  3. InfluxDB安装

    参考https://www.influxdata.com/downloads/#influxdb 官网 OS X brew update brew install influxdb Docker Im ...

  4. Codeforces Round #334 (Div. 2) B. More Cowbell 二分

    B. More Cowbell Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/probl ...

  5. HDU 4813 Hard Code 水题

    Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  6. Oracle 生成随机密码

    需求:需要定期更改密码.要求是1.密码位数11位.2.必须包含大小写字母.数字.特殊字符.3.排除一些特殊字符如().@.& oracle数据库中有可已生成随机密码包dbms_random,但 ...

  7. sharepoint 2013 未能加载类型"Microsoft.AnalysisServices.SharePoint.Integration.ReportGalleryView"

    最近在做PowerPivot for sharepoint server 2013的时候,创建PowerPivot库,之后打开,出现了一个问题: 未能加载类型"Microsoft.Analy ...

  8. iOS开发——数据解析Swift篇&简单json数据处理

    简单json数据处理 //loadWeather var url = NSURL(string: "http://www.weather.com.cn/adat/sk/101240701.h ...

  9. 关于AS3的垃圾回收

    FlashPlayer运行GC(Gabage Collection)的时间并不固定,它会根据你的内存的占用情况来决定运行GC的时间.它会根据用户机器的内存值来设定一个阀值,然后将程序的占用内存量保存在 ...

  10. 贪心算法(2)-Kruskal最小生成树

    什么是最小生成树? 生成树是相对图来说的,一个图的生成树是一个树并把图的所有顶点连接在一起.一个图可以有许多不同的生成树.一个有 n 个结点的连通图的生成树是原图的极小连通子图,且包含原图中的所有 n ...