VS2019 WPF package installer latest tutorial, use Visual Studio 2019 WPF application development package if you want to install the program, in addition to find WPF class library project in VS2019 release just right, it is more common or package it into the exe or msi Setup; then packaged into the installer, customers receive installation program can be installed directly use, even in the offline environment, the installed ready for use.
Some of the traditional publishing industry program, this method is more commonly used, such as health care and education.
Demo package list
In this tutorial, I packed complete a simple WPF program, installed after the final, I have a desktop program shortcut icon, click on this icon to open the application.
Effect after run as follows:
Package Installer step VS2019 WPF
There are packaged using VS2019 WPF installer are many ways, this tutorial VS extensions based on Microsoft Visual Studio Installer Projects tool to package, in fact, this tool comes with VS2010 there when, just behind the version of Visual Studio canceled this plug-in, now we need to be installed separately.
Installer plug-in installation package
There are two ways to install Microsoft Visual Studio Installer Projects plug-ins. First, download a separate plug-in installation, the second is inside the VS line installation.
Microsoft Visual Studio Installer Projects Download:
Official Download: Download
After downloaded, you will see in your save folder icon in this file is the case, simply double-click to install it, if you open the Visual Studio, VS first off and then installed.
If you can not download from the official website, you can download it directly from the site. Download and install the offline way off the network environment suitable for development.
Online VS install Microsoft Visual Studio Installer Projects
Microsoft Visual Studio Installer Projects插件也可以在线直接安装,步骤为:点击菜单栏【扩展(X)】,然后在弹出来的一个窗体里面,在右侧搜索框里面搜索“Microsoft Visual Studio Installer Projects”,一般第1个就是它了,然后点击Download(下载),然后安装就可以了。
点击Download后如下:
下载完毕后,你需要把VS关闭掉,它会自动的安装。
安装好了后,启动VS即可。
创建安装项目
重新打开Visual Studio,打开一个你现有的包含WPF项目的解决方案即可,然后创建安装项目。在解决方案上右键 –> 【新建项目】–> 【Setup Project】,添加Setup Project项目时,VS2019可以搜索项目模板,如下图所示。
创建好了后,主界面变成如下图所示:
左边窗口三个文件夹图片说明如下:
Application Folder:应用程序包含的文件设置,指最终在客户电脑上的安装根目录。如下图所示:
User’s Desktop:用户桌面快捷方式设置,用户桌面,一般放个快捷图标。
User’s Programs Menu:用户启动菜单的快捷方式设置,一般也是放快捷图标。
Application Folder是安装程序的根目录,你编写的程序生成的dll,安装后就存放在这个目录。
添加项目输出
安装项目建好了后,需要要往里面添加项目输出,操作方式为:右键Application Folder —>Add—>项目输出。
该操作也可以直接在安装程序项目类库上面通过右键操作来添加项目输出,如下图所示:
设置项目属性
项目属性的设置,是用于最终一个生成安装程序的描述信息,这个描述信息,这个描述信息主要内容有程序的作者,标题,公司信息,技术支持等等。最直观的方式可以通过2种方式查看。
第一种查看方式:安装前将鼠标放到安装程序文件上,会有提示信息,如下图所示:
第二种查看方式:安装后在控制面板处,找到安装程序,即可查看,如下图所示:
项目属性的设置方式为:(1)左键选中项目,(2)点击解决方案栏属性,注意,不是右键选择属性,而是如下图一样选择属性。
当你点了属性后,会出现如下的窗口。
在当前的演示程序中,我是按照上图做的设置,设置都很简单,不需要做额外的解释,如果有不明白的,可以加群与我联系。
添加快捷方式图标
程序安装好,我们当然希望用户能够快速的打开我们的应用程序,你就需要为你的安装程序制作快捷方式,方法很简单。
方法:(1)中间窗口右键,创建新的快捷方式
(2)弹窗里面选择Application Folder,双击进入另外一个界面
双击后,进入下图这个界面,选择主输出即可。
完了后点击OK按钮,就进入下图这个界面。然后将快捷方式名称改为你应用程序的名称。
改名后的效果:
最后一步,也是最重要一步,在上图中选中改名后的图标,将其拖到左侧窗口User’s Desktop目录即可。
开始菜单图标(User’s Programs Menu)设置方式同上面的步骤是一样的,这里就不再重复了。
依赖文件
打包正式项目的时候,界面程序可能依赖于很多其它类库,或者第3方的dll文件,我们需要把它们一起打包,并且这些第3方程序或者dll需要同主程序在同一个安装路径下,那么在打包时,也就需要额外的把这些文件也打包进来。
所有的操作都可以在中间窗口通过右键添加文件,程序集来实现,如下图所示
添加注册表项目
制作的安装包如果要添加注册表项目,可以通过选中安装程序项目,然后右键,在弹出的菜单里面找到【View】,即可以添加注册表项目,按照提示一步一步操作即可。
另外有些打包的程序,需要在安装前或者安装后做一些额外的操作,都可以通过自定义操作来实现,如主程序安装好了以后,还得安装一个windows服务程序,再安装另外一个自动升级程序,都可以通过这里来实现。
以上的基本操作熟悉后,相信对于简单的桌面程序打包应该没有什么问题了。
另外需要注意的是,对外打包,需要更改为Release模式
打包依赖框架
最后再说一下关于 .net 环境的问题,如果你需要在打包时,将相应版本的.Net Framework一起打包到安装程序里面也是可以的,只是要注意,有可能你的打包机器上并没有安装相应的.net framework文件,则需要到官方或者网上下载对应版本的文件,例如这个演示程序,我设定的依赖框架是 4.5.2版本的,那么需要将NDP452-KB2901907-x86-x64-AllOS-CHS.exe(.net framework 4.5.2安装文件)放到指定目录才能正常的生成打包文件。
需要将.net 的离线安装文件放到以下目录,其它版本则注意下路径即可,一般C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages
目录下面有不同版本的以DotNetFX开头的目录,如下图所示:
将相应的版本的.net framework框架文件放到对应的目录即可,我这个演示程序是放到下面这个目录的。
C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX452\zh-Hans
具体打包步骤为:右键安装项目,选择属性,弹出窗口点击Prerequisites…按钮。再在弹出的窗口选择你应用程序需要的框架版本即可。可以选择多个。
选择需要打包的框架版本即可。
待安装程序打包成功后,即可在生成目录看到该框架的安装包,如下图所示:
Well, that's the complete package using VS2019 WPF step installer.
Click here to download the demo can.
After the package installation list
After packing into a raw file successfully, you can double-click or msi exe file to install, the installation effect is as follows:
Select the installation directory
In this presentation package program which is relatively simple, in fact, you can add user agreement file, enter your user information to install, these can be set at the time of packaging.
Demo program source code can be downloaded at the original link
This article first appeared: https://jhrs.com/2019/33231.html