. Net application package deployment Summary

Source: Internet
Author: User
Tags visual studio 2010

After the source code is compiled and tested, the development process is not completed. In this extreme, you need to provide the application to the user. Whether it is an ASP. NET application, a client application, or an application built by the Compact Framework, the developed software must be deployed in the target environment .. The deployment of NET Framework is much easier than before, because you no longer need to register COM components or write new registry configurations.

Remember that when installing a program, you often need to install the registry key or something. NET does not need to operate the registry at all.

During the deployment process, the biggest problem is the solution to the dependency problem of the third database. Third-party class libraries for development may be installed on the developer's computer in advance. For example, we often need to use opencv or emgucv class libraries for graphic processing, however, these third-party libraries are not installed on the target computer. In this way, the corresponding class library needs to be installed on the target computer during deployment. The deployment process may be very complex for large applications, just like the deployment of call of duty, or the deployment of Visual Studio. During the deployment process, you can choose which components can be installed, which components cannot be installed.

This article briefly introduces the basic deployment methods and serves as an example. If you want to write a very powerful deployment function, you still need to learn more documents and materials.

Deployment classification in. NET: 1. XCopy

XCopy allows you to copy an assembly or a group of assembly to the application folder of the target computer to reduce development time .. NET assembly is self-contained (metadata describes the content contained in the assembly), because registration is not required in the registry.

Each assembly tracks other assembly to be executed. Therefore, by default, the Assembly looks for dependencies in the current application folder. This is why when our program references a third-party Assembly, we can put the third-party assembly under the application folder to run correctly and promptly move the application to another computer.

2. Publish a Web site

Before publishing a Web site, the entire site is compiled and copied to the specified location. The compiled site does not contain any source code.

3. Deploy the project

Deploying a project is a common installation method. VS2010 allows you to create an installer for an application. There are four options based on the Windows Installer technology:

Create merging Module

Create an installer for the client application

Create an installer for a Web application

Create an installer for smart device-based applications

If you have created a cab file and used a windows moblie operating system, all the installation programs in the system are cab files, and the cab Installation File is also used in the win ce system.

4. ClickOnce Technology

ClickOnce technology can be used to build automatically upgraded Windows-based applications.

ClickOnce allows applications to be published to Web sites, file sharing, or CD. After upgrading or updating applications, the development team can release them to the same location or site. When users use the application, the application automatically checks whether the latest version is available. If yes, update the version.

Next, we will introduce in detail each deployment method.

Deployment Method

 

1. XCopy deployment

XCopy deployment copies a group of files to a folder on the target computer, and then runs applications on the client. Regardless of the number of assemblies, if you copy files to the same folder, the application can run. You do not need to configure the settings or registry.

To put it simply, XCopy deployment is to copy the assembly to the target computer, and then deploy fully functional applications. This method limits the size of the deployable assembly.

Disadvantages of XCopy deployment: the Assembly cannot be placed in the Global Assembly Cache (GAC), and icons cannot be added to the Start Menu. If the program depends on a certain type of COM library, you cannot easily register COM components.

2. Publish a Web site

XCopy can also be used for publishing Web applications. Create a virtual directory and copy the Web application files to the virtual directory.

Another deployment option of the Web project is to publish a Web site. Publishing a Web site is to pre-compile the entire site and put the compiled version at the specified location. VS has a user guide for publishing a Web site, follow the wizard prompts to perform the operation.

The advantage of Web site publishing is its fast speed and high security. The speed is fast because all the Assembly has been compiled.

Iii. Visual Studio 2010 installation and deployment project

XCopy is very simple to use, but lacks some features. Visual Studio 2010 provides six installer project types. Four of them are based on the Windows Installer technology.

.

The Project is deployed to the folder structure, while the Web Setup Project is deployed to the virtual directory of the Web server.

When creating components or function libraries that are included in multiple deployment projects, you generally use the Merge Module Project. By creating a merging Module, you can set configuration items dedicated to components, you don't have to worry about them when creating a primary project.

3.1 Introduction to Windows Installer

Windows Installer is a service that manages the installation, update, repair, and deletion of applications on most windows operating systems.

Windows Installer tracks application installation in the database. When you uninstall the application, Windows Installer and content track and delete the added registry settings and files copied to the hard disk, and the added desktop icon and the icon in the Start Menu. If the registry settings or the DLL related to the application procedure is accidentally deleted, you can fix the installation. During the restoration process, the installer reads the database from the previous installation and retries the installation process.

If you need to leave more blank, you should check the Windows Installer SDK, which is part of the Platform SDK, which contains the document for creating an Automatic Installation Software Package for the application.

3.2 Create an installer

The first task of creating the installation package is to identify all the external resources required by the application, the treasure-store configuration file, COM components, third-party class libraries, controls, and image resources.

This section describes how to create an installer project in an independent solution. Then we will introduce how to create an installer project in the original solution.

The examples we use here are all a Adaboost-Based Face Detection Program, which uses a third-party class library of Emgucv.

3.2.1 create an installation project in an independent solution

Before creating a deployment project, make sure that the deployed application has a Release version, that is, the Release version.

Create a Setup Project and enter relevant information,

Then you can see the following interface:

In 'solution Explorer, right-click the project, select Add, and select Assembly.

Add the required assembly for this project. Select the facedetecttest.exe that has been releaseed, And then you can see that in the Detected Dependencies section, Vs provides the Assembly dependency required for this executable file. In this way, Vs automatically contains the assembly. Dependent assembly

Then you need to determine where to deploy the Assembly to your computer.

Click the root of the list on the left and right-click the blank area to add a special folder. You can add a special folder as needed. Here we have added the GAC folder. However, the Assembly added to the GAC folder must be desperate. After adding GAC, drag the Assembly to which GAC is to be placed into it.

Next, you can add shortcuts to the desktop or start menu. You need to drag the shortcut to the corresponding folder.

To create a desktop shortcut, go to the Application folder and right-click the program in the Application folder to create a shortcut,

Select "Create Shortcut to FaceDetectTest. ext" and then generate a Shortcut for this application.

Drag the shortcut file to the User's Desktop folder, so that a program shortcut is displayed on the User's Desktop during installation.

Then Build the entire project to obtain the installation file.

3.2.2 create an installation project in the same solution

The preceding deployment method has several disadvantages: for example, if you are careful about adding an assembly to the original application summary, the deployment project will not automatically identify any changes, but you must manually add a new assembly, then, the dependency items of Yancheng's heart are included. If the application contains dozens or hundreds of application sets, it is difficult to maintain them. VS provides a simple solution. The deployment project is included in the application solution, so that the output of the main project can be used as the deployment assembly.

In the original solution, add a new Project and select Setup Project.

The above installer adds an assembly through Add-> Assemblies. This time, we Add an assembly through Add-> Project Output.

In the displayed window, select the project to be added and select "Primary Output ",

This includes the output and all dependencies when building an application. Set Configuration to Release x86

The system still automatically detects the dependency and primary output:

The remaining operations are the same as those for creating and installing a project.

You can obtain the installer file.

Advantages of this method: when a new project is added to the solution and a new reference is added to the original project, the deployment project automatically selects a new assembly, we don't need to do anything.

Iv. ClickOnce deployment

ClickOnce is a deployment technology that allows applications to be automatically upgraded. Applications are published to shared files, Web sites, or other media. If the program publisher upgrades the program, ClickOnce automatically detects the upgrade of the program version without user interference.

ClickOnce also solves the security permission issue. Generally, to install an application, you need to manage the permissions. With ClickOnce, you can install and run applications as long as you have the minimum absolute permissions required to run applications.

How to publish a ClickOnce application:

Right-click the project for which you want to create the ClickOnce installation method, and select properties. The following page is displayed:

Select Publish,

To publish a ClickOnce application, you must work with the IIS server.

Here, I put the ClickOnce application on the local IIS server.

Click Publish.

Then you can install the application by accessing the address in the browser.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.