Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the steps for C # to package desktop applications with InstallerProjects

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What are the steps for C # to package desktop applications with InstallerProjects? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Preface

Packaging desktop applications is really an infrequent thing, and it often takes time to forget things when used occasionally, so this article mostly records the process with pictures and is also used as a memo.

Download Packaging tool

There are many ways to package desktop applications in C #. Here is a way to package desktop applications using Microsoft Visual Studio Installer Projects tools.

First, let's create a Windows desktop application

Next, we select the tool and click expand and Update.

And then we get the interface as follows

The interface displays the installed content by default. If we take a closer look at the content, we will find that here are all the tools we have installed. If we take a closer look, we will find that most of the tools here are created by microsoft, that is to say, the tools here are officially provided to us.

Because we want to download tools that do not exist on this machine, we click the "online" button on the left menu, and then type Microsoft Visual Studio Installer Projects in the search box in the upper right corner to retrieve it.

Then we select the Microsoft Visual Studio Installer Projects option, click download in the upper right corner of the option, and download the tool locally.

When the download is complete, we will find that there is such a prompt at the bottom of the current form.

This prompt tells us that although the tool has been downloaded, it has not been installed yet, and we need to close Visual Studio before we can install it.

After closing Visual Studio, the following prompt box will pop up automatically, and we will be prompted whether we will allow it or not, and we will select [Yes].

Next, the window will display the relevant contents of the tool, with a modify button added below

We click modify, and the tool will be installed automatically.

Create a packaged project

After waiting for the tool installation to complete, we reopen Visual Studio and open the WPF project we just created.

In the solution where the WPF project is located, we right-click to create a new project, and then select "other Project types"-"Setup Project" on the left menu to create an installation project KibaInstallSetup.

Click OK, we can see the following window.

The window on the left side of the window has three folder pictures, corresponding to the following contents:

Application Folder: the file settings included in the application.

User's Desktop: user desktop shortcut settings.

User's Programs Menu: shortcut settings for the user's startup menu.

Let's first look at how Application Folder is used, first select Application Folder, and then right-> Add- > project output.

After clicking, the [add Project output Group page] pops up, as shown in the following figure. Because there is only one project under the solution, there is only one option in my project selection.

Click OK, and we successfully add the main output of the project, as shown below:

At this point, we right-click our installation project KibaInstallSetup- build, and we can already generate the executable file for the project.

However, at this time, the installation file is the most basic installation file, there is no customization.

Let's add desktop shortcut icons and start menu shortcuts to the installation file, and modify the author, description, and other information of the executable file.

Package project property configuration

Project attribute

Let's first change the basic information of the installation file.

First of all, we left-click to select the project, and then select the properties, note that instead of right-selecting the properties, we select the properties as shown in the following figure.

After clicking, modify the author and description

Desktop shortcut

Now let's modify the shortcut picture of the installer.

Left-click User's Desktop, then move the mouse to the right form, and right-select create New Shortcut.

Then, the system pops up an interface for us to select .ico files, but there are only three folders in the interface, corresponding to the three folders in the upper left corner of our installation project, as shown below:

Now let's double-click the first application directory option, then click Add File, add a logo.ico file to the installation directory, and finally click OK.

In this way, we have successfully created a desktop shortcut, as shown in the following figure.

Now, we right-click the Shortcut to logo.ico, change its name to Kiba, and then left-click to select to view its properties.

As you can see, our shortcut has successfully pointed to our main output, and the Icon has been modified. If you are not satisfied with pointing and Icon, you can modify it twice in the property.

User menu shortcut

The shortcut to the user menu is set in User's Programs Menu, which is set in exactly the same way as the desktop shortcut.

Dependency files and dependency frameworks

Dependent file

When we package an application, we sometimes need some dependent files, which cannot be referenced by the main program, but also need to be in the same installation path as the main program, so when packaging, you also need to package these files.

The way to add additional dependent files is simple: select Application Folder, and in the corresponding right-hand form, right-Add- the file

Then, select the file in the pop-up Select File dialog box.

Dependency framework

Sometimes our applications need to be installed on a computer without Framework, so when we need to package, package the Framework, or prompt the user to download it when installing.

We right-click the project, select Properties, and then click Prerequisites in the pop-up property page

Then, in the prerequisites form, check Framework 4.6.1 and select download prerequisites from the component vendor's website.

In this way, when our executable file is running, it will prompt the customer to download Framework 4.6.1 from Microsoft's official website.

Of course, we can also package Framework 4.6.1, but this requires us to download the Framework installation package in advance, and then choose to download the prerequisites from the following location, so that the grayed out Browse button can be used.

After reading the above, have you mastered the steps of using InstallerProjects to package desktop applications in C #? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report