打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
2015 visual studio installer project的使用总结

 

一.安装

1.可在扩展和更新中查找搜索安装,也可在官网直接下载插件连网安装,之后重启visual studio软件;

2.针对需要安装的已开发的项目,在解决方案右键新建项目--其他项目类型--setup project;

二.配置部署安装包平台项目

1.已创建成功的项目名为xx安装包平台,此时项目是空的,需在项目右键属性--add

 

项目输出:选择要打包的项目名称,可自动输出相关联的程序集,以及主输出xx文件,但本地config等文件,需要手动添加;

文件(F)...:可以手动添加所需要的所有文件;

程序集:可手动从network或者本地添加引用;

2.在完成add添加之后,开始对安装步骤及特性进行配置,项目右击属性--view

对于常规安装使用包括文件系统,用户界面,自定义操作及启动条件;

1).文件系统包括三大部分:application folder,user's desktop,user's program menu;

application folder主要是对要安装的各类文件进行属性的一些修改操作,包括安装条件condition,是否排除exclude,及文件名等等;

user's desktop:桌面快捷方式--启动可添加至此

user's program menu:电脑开始菜单栏--卸载可添加至此,卸载程序可从system32/msiexec.exe拷贝至此,并将快捷方式-属性的Arguments修改格式:

/x 空格 ProductCode

2).软件安装过程的界面交换及操作可通过 view-用户界面进行配置修改:

可在启动界面 start右击添加文本框,复选框,客户信息等交互界面:

以文本框为例:

添加文本框界面后,点击该文本框,可在属性中进行修改配置:

文本框输入的内容如何被安装程序获取并写到本地文件或者sql数据库中;

3).自定义操作包括install,commit,rollback和uninstall

自定义操作有4个阶段:Install 是在所有文件安装完成后执行。Commit是正确安装完成后会执行。RollBack在回滚执行。Uninstall在卸载时执行。

自定义安装的类需继承    System.Configuration.Install ,需添加该程序集;

若需要在自定义不同的阶段执行不同的方法及触发所需要的事件,需要重写包括添加事件等等

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.IO;

namespace xxxx
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
       
        //protected override void OnBeforeInstall(IDictionary savedState)
        //{
        //    //从用户界面获取的参数
        //    port = Context.Parameters["Port"];
        //}

        public ProjectInstaller() :base()
       {
            // Attach the 'Committed' event.
            this.Committed = new InstallEventHandler(ProjectInstaller_Committed);
            // Attach the 'Committing' event.
            this.Committing = new InstallEventHandler(ProjectInstaller_Committing);
        }

        // Event handler for 'Committing' event.
        private void ProjectInstaller_Committing(object sender, InstallEventArgs e)
        {
            Console.WriteLine("");
            Console.WriteLine("Committing Event occured.");
            Console.WriteLine("");
        }
        // Event handler for 'Committed' event.
        private void ProjectInstaller_Committed(object sender, InstallEventArgs e)
        {
            Console.WriteLine("");
            Console.WriteLine("Committed Event occured.");
            Console.WriteLine("");
        }
        // Override the 'Install' method.
        public override void Install(IDictionary savedState)
        {
            base.Install(savedState);
        }
        // Override the 'Commit' method.
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
        }
        // Override the 'Rollback' method.
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);
        }

        protected override void OnAfterInstall(IDictionary savedState)
        {
            string editb1 = this.Context.Parameters["editb1"];
            string path = "c:\\testtxt.txt";
            FileStream fs1 = new FileStream(path, FileMode.Create, FileAccess.Write);//创建写入文件               
            StreamWriter sw = new StreamWriter(fs1);
            sw.WriteLine(editb1);//开始写入值
            sw.Close();
            fs1.Close();
        }


    }
}

 

 visual studio installer project可以完成的功能

1.安装界面的文本框数据可以在自定义操作的类中获取并写入文件中;

在自定义操作的install添加自定义操作,并修改属性如下:

CustomActionData=/editb1=[EDITB1]

并在自定义installer类中对parameter-editb1进行读取等操作;

2.复选框用户界面可以让用户选择性的安装某些文件或者不装某些文件;

通过复选框界面的属性可以配置标题及主题信息,同时修改复选框名称;

在application foder,对需要选择进行安装的文件的属性 condition进行配置如下:

Condition  CHECKBOXA1=1     勾选代表要安装,取消勾选则代表不安装;

3.在创建的安装项目的属性界面,可修改 author,productname,manuafacture等信息;

4.关于msiexec.exe的警告无需处理,因为msiexec.exe文件是受Windows保护,所以弹出警告。

关于dll对象重复的警告,删除一个即可。

5.对项目右击--属性界面,可配置release/debug输出,msi名称,packagefile,prerequistes等信息;

6.msi安装包不检测,直接安装,setup.exe会检测是否满足安装条件;

 

来源:https://www.icode9.com/content-4-744701.html
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
VS打包同时运行其他程序或命令的相关资料收集
VS2010 部署程序在安装完成后自动启动外部程序
c#中的多态
UI--Android中的状态切换按钮自定义
虚方法
简述c#之sealed 修饰符
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服