0


c# 项目文件 打包成exe安装包 (vs2015)

一、准备工作

1 Visual Studio 2015 必须有相关的打包组件;
2 Visual Studio的打包组件有 InstallShield 和 Visual Studio Installer Projects (安装包:VSI_bundle)组件;
3 Visual Studio Installer Projects还可在VS软件中下载,下载方式如下:
a)点中菜单栏的“工具”选项,并选中“扩展和更新”;
在这里插入图片描述

b)在搜索框输入 Visual Studio Installer Projects ,然后选中Visual Studio Installer Projects 安装。
在这里插入图片描述

二、使用 Visual Studio Installer Projects 打包项目

1、 创建项目,可在菜单栏点击 文件——>新建——>项目,也可在当前解决方案上右键,然后选择 添加——>新建项目
在这里插入图片描述

2 选中 其他项目类型 ——> Visual Studio Installer ——>Setup Project ,然后编辑 名称 和 位置 。
在这里插入图片描述

3 新建的 工程文件 如下图所示。
在这里插入图片描述
工程中包含三个文件夹:
Application Folder:存放打包项目包含的所有文件;
User‘s Desktop:存放安装后要置于桌面的文件;
User’s Programs Menu:存放安装后在“开始菜单”内显示的文件;

4 打包文件包含可执行exe(或项目主输出)文件及项目运行包含的脚本、外部添加的dll文件等相关依赖项。
添加方法:
a)点中 “Application Folder” 选项,然后右击,移动至“Add”上;
Folder:添加文件夹;
项目输出:可添加项目的输出文件;
文件:项目运行包含的脚本、外部添加的dll文件等;
程序集:添加项目依赖项,一般在“文件”处就添加了。
在这里插入图片描述

b)添加项目主输出文件,点击 “项目输出”,在“项目”处选择需要打包的项目,点中“主输出”,然后点中“确定”。(这里添加项目生成的 .exe 文件也是一样的)
在这里插入图片描述

c)添加程序运行需要的 脚本及外部添加dll文件 等,右击 “Application Folder” 文件夹空白处,选择需要添加的 文件和文件夹。
在这里插入图片描述

d)添加 快捷方式
1、选中“主输出”文件或添加的 “.exe” 文件,右击选择 “Create Shortcut to” ;
2、点击生成的文件,将其移动至 “User‘s Desktop” ;
3、在 “User’s Programs Menu” 中新建Folder,生成一个文价夹;
4、回到 “Application Folder” 文件夹,选中“主输出”文件或添加的 “.exe” 文件,右击选择 “Create Shortcut to” ;
5、点击生成的文件,将其移动至 “User’s Programs Menu” 生成的文件夹中;
在这里插入图片描述

e)添加卸载程序的exe文件
1、右击 “Application Folder” 文件夹空白处,找到 “msiexec.exe”文件,在路径处粘贴 “C:\Windows\System32” ,找到 “msiexec.exe” 文件,点击 “打开”。
在这里插入图片描述

2、选中“msiexec.exe”文件,右击选择 “Create Shortcut to” ,并将生成的文件名改为 “uninstall” ;
在这里插入图片描述
在这里插入图片描述

如下图所示。
在这里插入图片描述

3、选中 解决方案资源管理器 中的打包项目,复制 属性的ProductCode 值。
在这里插入图片描述

4、选中 “uninstall” ,将复制的 ProductCode 值粘贴至 “uninstall” 属性的 Arguments处,并在最前面添加 /x及一个英文空格。
在这里插入图片描述
在这里插入图片描述

f)添加程序图标(应用程序及卸载程序)
1、选中需要更该的应用图标。
在这里插入图片描述

2、点中 属性框中Icon ,选中 (Browse … …)
在这里插入图片描述

3、在弹出窗口中 点击 Browse
在这里插入图片描述

4、双击 “Application Folder”
在这里插入图片描述

5、选中 添加的 ico 文件
在这里插入图片描述

6、点击 OK
在这里插入图片描述

g)更改应用在 “卸载或更改程序” 中的图标
选中打包项目文件,在 “AddRemoveProgramsIcon” 项按f)步骤更改图标。
在这里插入图片描述

h)更改安装文件路径
选中 “Application Folder” ,在 DefaultLocation 处 将[ProgramFilesFolder][Manufacturer][ProductName] 改为 C:[Manufacturer][ProductName],安装文件夹由 C:\Program Files[Manufacturer][ProductName] 改为C:[Manufacturer][ProductName] 。
在这里插入图片描述

i)设置setup的启动条件,判断net是否安装
一般打包的应用程序运行框架中,会依赖“. net Framework”版本环境,所以为确保应用安装并正常运行须先保证系统配置有指定版本及以上版本的依赖项。
1、选中项目,右击——>View——>启动条件
在这里插入图片描述

2、选中 Net Framework ,在其属性页 Version 项,选择对应的 .Net Framework版本。
在这里插入图片描述

j)配置完成,生成项目安装包
1、选中 打包项目,右击,点击生成。
在这里插入图片描述

2、生成后的问件夹。
在这里插入图片描述

3、生成后Debug包
在这里插入图片描述

三、其它

1 打开打包项目的文件系统
在这里插入图片描述

2 主输出或exe的属性
在这里插入图片描述
序号名称中译1Condition条件2Dependencies依赖3Exclude排除4Exclude Filter排除筛选器5Folder文件夹6Hidden隐藏7Key Output键输出8Outputs输出9Package As打包为10Permanent永久11Read Only只读12Register注册13Shared Legacy共享遗产14System系统15Transitive及物16vital重要
3 打包项目的属性各项涵义
在这里插入图片描述
序号名称解释中译译文1Add Remove Programs IconSpecifies an icon to be displayed in the Add/Remove Programs dialog box on the target computer.“添加/删除程序”对话框中显示的图标指定要在目标计算机上的“添加/删除程序”对话框中显示的图标。2AuthorSpecifies the name of the author of an application or component.作者指定应用程序或组件的作者姓名。3Backward compatible ID GenerationTrue specifies Visual Studio 2008 (and earlier) lD generation; False specifies Visual Studio 2010 ID generation.向后兼容的 ID生成True指定 Visual Studio 2008(及更早版本) lD 生成;False 指定 Visual Studio 2010 lD 生成。4DescriptionSpecifies a free-form description for an installer.描述指定安装程序的说明(自由格式)5Detect Newer Installed VersionSpecifies whether to check for newer versions of an application during installation.检测较新的安装版本指定是否在安装过程中检查应用程序的较新版本。6Install All usersSpecifies whether the package is installed for all users or only the installing user.所有用户均可安装指定是为所有用户安装包还是仅为安装用户安装包。7KeywordsSpecifies keywords used to search for an installer.关键字指定用于搜索安装程序的关键字。8LocalizationSpecifies the locale for string resources and the run-time user interface.地方化指定字符串资源的区域设置和运行时用户界面。9ManufacturerSpecifies the name of the manufacturer of an application or component.制造商指定应用程序或组件的制造商的名称。10ManufacturerUrlSpecifies a URL for a Web site containing information about the manufacturer application or component .制造商网址指定包含制造商相关信息的网站的 URL应用程序或组件。11Post Build EventSpecifies any commands to execute after the build ends.后期构建事件指定要在生成结束后执行的任何命令。12Pre Build EventSpecifies any commands to execute before the build starts.预构建事件指定在生成开始之前要执行的任何命令。13Product codeSpecifies a unique identifier for an application.产品代码指定应用程序的唯一标识符。14Product NameSpecifies a public name that describes an application or component.产品名称指定描述应用程序或组件的公共名称。15Remove Previous VersionsSpecifies whether an installer will remove previous versions of an application during installation.删除以前的版本指定安装程序是否在安装过程中删除应用程序的早期版本。16Run Post Build EventSpecifies the condition under which the post-build event runs.运行生成后事件指定运行后期生成事件的条件。17Search PathSpecifies the path that is used to search for assemblies, files, or merge modules on the development computer.搜索路径指定用于在开发计算机上搜索程序集、文件或合并模块的路径。18SubjectSpecifies additional information descrioing an application or component.主题指定描述应用程序或组件的其他信息。19Support PhoneSpecifies a phone number for support information for an application or component.支持电话指定应用程序或组件的支持信息的电话号码。20Support UrlSpecifies a URL for a Web site containing support information for an application or component.支持网址指定包含应用程序或组件支持信息的网站的 URL 。21Target PlatformSpecifies the target platform of the installer.目标平台指定安装程序的目标平台。22TitleSpecifies the title of an installer.标题指定安装程序的标题。23Upgrade CodeSpecifies a shared identifier that represents multiple versions of an application.升级代码指定表示应用程序的多个版本的共享标识符。24VersionSpecifies the version number of an installer, merge module, or .cab file.版本指定安装程序、合并模块或.cab文件的版本号。

标签: c# microsoft windows

本文转载自: https://blog.csdn.net/jk_rou/article/details/130307402
版权归原作者 Love朴啾啾 所有, 如有侵权,请联系我们删除。

“c# 项目文件 打包成exe安装包 (vs2015)”的评论:

还没有评论