VB.net installation and deployment project

Source: Internet
Author: User

[Learning objectives] This module describes the "installation and deployment project" function in VB. NET. Use "Install and deploy project" to generate the browser form of WebService and browser of browse client in B/S mode.ProgramAnd the installation file of the Windows application client program in C/S mode. Then, install and deploy the project on the other computer using the generated three installation files.

Application installation and deployment is a very important task, because the ultimate goal of application development is to allow the majority of users to use, however, each user's computer cannot be required to install the development environment of programming software. applications written on. NET can be installed on other machines and can be detached from VB. in addition to complex manual installation, the most convenient method is to use VB. net to install and deploy applications on other computers.

10.1 generate an installer for the WebService Program

[Case 10-1] generate an installation file for the WebService program.

This case mainly introduces the use of VB. net "installation and deployment project" function how to create a WebService installation file, the user can use this life-cycle Installation File to correctly install and deploy the WebService to other computers.

[Skill Objectives]

Use the "installation and deployment project" function in VB. NET to generate the installation program of the WebService Service Program.

[Key Points and steps]

The following describes how to use the "Install and deploy project" function in VB. NET to generate a WebService Installer:

1. in.. Net open the solution file "D: \ Inetpub \ wwwroot \ translatewebservice" in case 9-1 of Unit 9. SLN. After the solution file is opened, select "File> Add project> New Project". The "new project" dialog box is displayed.

2. in the "Create Project" dialog box, select "installation and deployment Project" in "project type", and select "Web Installation Project" in the "template" list ", in the "name" text box, enter the project name "webservicesetup". In the "location" text box, the opened project file "translatewebservice" is automatically filled in. path of vbproj: "D: \ Inetpub \ wwwroot \ translatewebservice ". Click OK. The system automatically creates the source file related to the installer.

3. On the "File System" tab, select the folder marked as "Web application folder", as shown in Figure 10-1.

Figure 10-1 "File System" tab

4. in Solution Explorer, right-click the project name webservicesetup and choose add> project output from the shortcut menu, as shown in Figure 10-2, the "add project output group" dialog box is displayed. In the dialog box, select "main output", "localized resource", "debug symbol", "Content File", and "source file", as shown in 10-3, and click "OK, in the resource manager window, the output items selected in Figure 10-3 dialog box are displayed, as shown in Figure 10-4.

Figure 10-2 select "add> project output"

Figure 10-3 "add project output group" dialog box figure 10-4 interface after project output

5. on the "File System" tab, right-click "main output from translatewebservice (activity)", "content file from translatewebservice (activity)", and "source file from translatewebservice (activity) "," localization resources from translatewebservice (activity) "," debugging symbols from translatewebservice (activity, in the pop-up menu, select the "output" menu item, and then display the information boxes shown in 10-5, 10-6, 10-7, 10-8, and 10-9 respectively (note the content in the information box ). A brief description of the project output corresponding to the five charts is shown in Table 10-1.

Table 10-1 Brief description of project output

Brief description of project output

The main output is the EXE or DLL compiled by a specific project.

The content file output can only be used with ASP. NET and Web applications. It mainly contains HTML files, graphic files, and other content that forms the web site.

The output of the source file contains allSource codeFile, but does not contain the solution file

A localized resource is a dynamic link library that only contains resources. Resources in this library are used to describe files or locations, and are also called auxiliary dynamic link libraries.

The debugging symbol is a special file created when a specific project is compiled for detailed debugging information of the project. The debugging symbol of the project has the same name as the main output, but its extension is. PDB. When an application is running, the debugging symbol provides information to the debugging program.

 

Figure 10-5 main output from translatewebservice (activity) Figure 10-6 content files from translatewebservice (activity)

 

Figure 10-7 source files from translatewebservice (activity) Figure 10-8 localized resources from translatewebservice (activity)

 

Figure 10-9 "debugging symbols from translatewebservice (activity )"

6. if other files need to be packaged in the installer (for example, database files), right-click the bin folder on the "File System" tab, select "add> file" in the pop-up menu, as shown in 10-10. In the "add file" dialog box that appears, select the desired packaging file.

Figure 10-10 "add> file" menu

7. In Solution Explorer, right-click the project name "webservicesetup" and select "generate" from the shortcut menu, as shown in 10-11. The system will automatically generate a setup.exe installation file in the output folder of the installation program project, which is the installation program file. (The executable installation file is in the "D: \ Inetpub \ wwwroot \ translatewebservice \ webservicesetup \ debug" folder "), in the future, when installing and installing the WebService project on other computers, run this executable file directly (of course, the IIS service must be installed and started on the target computer ).

Figure 10-11 run the "generate" command

The Installation Process for generating client browser programs in B/S mode is similar to that for generating WebService programs in case 10-1. It is only different in the following aspects:

1. Open the solution file in case 9-2 in Unit 9. The solution file is "D: \ Inetpub \ wwwroot \ browse_client \ browse_client.sln ".

2. after the solution file is opened, enter the project name "browse_client" in the "file → add project → Create Project" menu dialog box ", in the "location" text box, the path of the opened project file browse_client.vbproj is automatically filled in: "D: \ Inetpub \ wwwroot \ browse_client ".

3.The system automatically generates a setup.exe installation file in the output folder of the installation program project. The folder where the installation file is located is in "D: \ Inetpub \ wwwroot \ browse_client \ browse_clientsetup \ debug ". Run this executable file directly when installing and installing the browse_client project on other computers in the future (of course, the IIS service must be installed and started on the target computer ).

 

[Related knowledge]

Because the WebService Service program can run normally only with the support of IIS, it must be published to a computer with IIS services for other programs to use. By default. when you create a WebService program in the. NET environment, the system automatically handles IIS problems. Therefore, you do not need to consider the running of the WebService program on the IIS computer. However, if you publish the created WebService program to other non-Vs services. in the. NET environment, you must correctly set IIS on the computer before running. For general users, it may be difficult to configure IIS and configure WebService programs. Fortunately,. NET provides the "Install and deploy Projects" function. You can use this function to conveniently generate installation files for the WebService Service Program, you can correctly install and deploy the WebService on other computers using the installation files generated in this lifetime.

Currently, the following methods are used to install and deploy application projects.

1. Manually register for Installation

2. Make executable installation programs

3. Windows Installer Service

4. installation and deployment of xcopy applications

To manually register for installation, you must first copy the application to the appropriate location and then perform other steps required for software installation, these other steps include registering components used by applications in the registry, and establishing necessary database connections. This method is generally not suitable for most common users. It is often only suitable for a few engineers with advanced and professional knowledge. This method is not only time-consuming, but also not flexible enough, however, this installation method is suitable for installing components on the server. through special registration and performance matching settings, the application can run better.

Using the tools provided by the integrated development environment, you can package all the files required for installation into an executable file, the executable file can be used to install and deploy the application project on other computers. This is a common method currently, this method is used in the case of this unit to create an application project installer. After the executable installer is created, it is very easy to run the executable installer to install and deploy the application project.

You can use the tools provided by the system programming software to prepare executable installation programs, or use specialized packaging tools produced by third-party manufacturers, such as the most common Install Shield and setup factory tools, these specialized packaging tools are suitable for creating installation files in large batches.

Windows 2000 is easier to manage and use than Windows 95/98. From the perspective of software installation and deployment, Windows 2000 uses the Windows installer Installer as a part of its service, which effectively solves the problems existing in the installation program in the previous operating system. Microsoft calls the Windows Installer Service an operating system component and executes all the rules required to meet the installation requirements. For example: in Windows Installer, the installer does not use components of earlier versions to overwrite system files, thus avoiding DLL traps of system components.

By using the Windows installerservice, you do not need to create an executable file setup.exe when installing the file in windows. Instead, you only need to create a Windows installer package file (. MSI file), which describes the operations required to install the application and the rules on these operations. In the final Windows installer package, an application is described as three components: components, features, and products. Each part is composed of the first part. For example, a product consists of several features, and a feature may consist of several components. A component is the smallest part of installation. It contains many files and other resources that need to be installed together. If the Windows Installer Service has been installed on the operating system, you can run the. MSI file. If the Windows installerservice is not installed, the installation file of setup.exe is created in the same way. This file first installs the Windows Installer Service and then runs the. MSI file.

The Windows Installer Service provides a rollback method when the installation fails. This method restores the operating system to the status before installation. In the previous installation method, if the installation fails, a pile of uninstalled junk files are left to occupy the system space. If the installation is heavy, the system enters an unstable state, it even causes a system crash. The Windows Installer Service solves this problem well.

The xcopy command of the DOS Operating System copies all files and directories in the file directory and its directory. It is an advanced version of the Copy command. In the DOS era, many applications were deployed in this way. If the application was very large at that time, it would be very difficult to deploy the application in this way. In Windows, it is not easy to achieve xcopy because of its complicated system mechanism. One of the reasons is that the registry mechanism is introduced in Windows (after 98), and the relationship between components and applications needs to be achieved by registering the key values in the system registry, the application needs to have an entry in the Registry to activate the components used. Due to this coupling of components, applications, and operating systems, it is impossible to simply install and use the complete application through application replication.

In Microsoft's. Net policy, we try to implement xcopy to install and deploy applications. CLR (Common Language Runtime) is trying to solve the coupling problem between the Registry and components, but currently it cannot completely handle the problems required by more advanced applications. In. net Framework, as long as the components used are based on. (.. NET Framework is so powerful that you can directly copy and use it without using other external components. This method is similar to xcopy deployment. However, this form cannot be considered a real xcopy, because the premise for deploying this xcopy method is that it must be preinstalled in the operating system. net Framework, which provides CLR. Other developers are optimistic that, as long as Microsoft's.. Net policy is widely used ,.. NET Framework is bound to the operating system, just like IE, so xcopy application deployment is not a castle in the air.

10.2 generate the installation program of client programs in C/S Mode

[Case 10-2] C/S client installer generation.

In this case, an installation file of the client program in C/S mode is generated. The user can correctly install and deploy the client program on other computers using the lifetime installation file, and create a shortcut for the client executable program in the desktop and program group.

[Skill Objectives]

Use the "Install and deploy project" function in VB. NET to generate an installation file for a client program in C/S mode.

[Key Points and steps]

1. in. open solution file "D: \ VB.net \ window_client \ window_client.sln", "Create client Windows Forms Program in C/S mode" in case 9-3 of Unit 9 ", after the solution file is opened, select "File> Add project> new project.

2. click "New Project". The "new project" dialog box is displayed. In the "project type" dialog box, select "Install and deploy project ", in the "template" list, select "Installation Project", and in the "name" file box, enter the project name as "window_clientsetup ", in the "location" text box, the path of the opened project file window_client.vbproj is automatically filled in: "D: \ VB.net \ window_client ". Click OK. The system automatically creates the source file related to the installer.

3. after the project is added, a new installation project window_clientsetup is added to solution resource manager. In this project, there is no content except an empty "detected dependency" node. Select the window_clientsetup project and mark it as "File System on the target computer" on the "File System" tab ", there are only three blank nodes in the "File System on the target computer. 10-12.

4. in Figure 10-12, a blank installation project cannot generate the required installation file. Therefore, you need to manually add some necessary content, including the output project and necessary files (for example: database files ). In solution Resource Manager, select and install the project window_clientsetup. Right-click the shortcut menu and run the "add> project output" command. The "add project output group" dialog box is displayed, see Figure 10-3. In the "add project output group" dialog box, content, configuration, and description under the window_client project are displayed, because in this solution, only the window_client project is installed, except for the window_clientsetup project, therefore, the output content is from the window_client project. The output content includes "main output", "localized resources", "debugging symbols", "content Files", and "source files, select all five items in this step (press Ctrl or shift to select multiple items when you use the mouse ), the meaning of the five output items has been briefly described in Table 10-1 In case 10-1.

After selecting all output items in Figure 10-3, click "OK" to add these five output items to the installation project window_clientsetup. In this case, you can find several more items in Solution Explorer, that is, five output items are added and one more item is added to the detected dependencies. This is. net automatically checks the dependencies of the output items when adding the output items, and includes necessary dependency files in the installation project.

Figure 10-12 blank File System

5. if other files need to be packaged in the installation file (for example, database files), on the "File System" tab, select the "add> file" menu in the pop-up menu, in the "add file" dialog box that appears, select the desired packaging file.

6. Add a specified folder

Sometimes you need to create a set of standard folders on the target computer. The folder may be an existing folder specified by the system on the target computer or a custom folder, at the same time, some project files are placed in these folders. This requirement can be completed by installing the file system editor of the project.

On the file system tab of window_clientsetup, select "File System on the target computer" and Right-click (or right-click in the blank area of the directory tree ), you can see the "add special folder" item in the pop-up shortcut menu, which contains many specified system folders, such as "common files" folder and "system folder, the last item is "Custom folder ". By executing these commands, you can directly create a folder in the file system. When the generated Installation File is installed on the target computer, the folder is automatically found or generated, and put the content in the specified folder. These folders are represented by system variables with square brackets [], which usually correspond to the specified folder on the system, as shown in 10-13.

7. Add shortcuts

The file system editor can also create a shortcut for the output project and place the shortcut under the specified directory, such as Common Desktop shortcuts and shortcuts in the program group.

After the application is installed, the installer automatically creates a shortcut for the application on the user's desktop and in the "program" menu to facilitate the user to run the application. In the installation project of VB. NET, you can use the file system editor to complete this work.

Figure 10-13 Add a specified folder

First, determine the target file for creating the shortcut key. Select the target file, right-click it, and execute the "Create XXX shortcut" command in the context menu to create a shortcut in the same folder as the target file. To create a shortcut for the target file in a folder different from the target file, you only need to copy the shortcut in the folder where the target file is located to the required folder.

Now, use the "main output from window_client" file under "application folder" to create a shortcut under the "user desktop" folder on the target computer.

First, select the "main output from window_client" file, right-click the pop-up menu, and execute "create primary key

Shortcut from window_client "command, as shown in 10-14.

Figure 10-14 select the "Create primary output shortcut from window_client" command menu

After executing the menu command, you can see that there is one more entry in the "Application folder", that is, "the main output is a shortcut from window_client, however, the user's ultimate goal is to create a shortcut under the "user desktop" folder of the target computer, that is, when the application is installed on the user's computer, to automatically generate a shortcut for the primary output on the user desktop, you must copy the shortcut under "application folder" to the "user desktop" folder. Select the shortcut, as shown in Figure 10-15, and run the cut command in the context menu.

Then, select the "user desktop" folder, as shown in 10-16, and right-click the pop-up menu and execute the "Paste" command to achieve the desired purpose.

 

Figure 10-15 select the cut menu in the pop-up menu

Figure 10-16 paste the shortcut menu to your desktop

In this way, there will be a "main output shortcut from window_client" in the "user desktop" folder. After you have installed the installation file generated by this project, you can see the shortcut on the desktop. If necessary, you can also change the name, icon, and other attributes of the shortcut in the file system editor of the installation project window_clientsetup, as shown in Figure 10-17.

Figure 10-17 set attributes such as the shortcut name and icon

Copy the shortcut menu in the clipboard to the user's program menu folder, and set attributes such as the shortcut name and icon. In this way, you can see the shortcuts and icons of the application on the desktop when installing the installation file generated by this project, you can also see the shortcut and icon of the application in the Windows Start Menu program.

8. in Solution Explorer, right-click the installation project name "window_clientsetup" and select "generate" in the shortcut menu. The system will automatically generate a setup.exe installation file in the installation project output folder, which is the installation program file, (The executable Installation File is located in "D: \ VB.net \ window_client \ window_clientsetup \ debug"). When you install and install the window_client project on other computers, run the executable file directly.

10.3 use the Installation Wizard to generate the installation program for the window_client Project

[Case 10-3] use the Installation Wizard to generate the installation program for the window_client project.

This case is based on VB.. Net Installation Wizard to generate the installation program for the window_client project in Unit 9 In case 9-3. the installation file generated by the Installation Wizard of. Net can correctly install and deploy the client window_client project to other computers.

[Skill Objectives]

Use the Installation Wizard of VB. NET to generate the installation program.

[Key Points and steps]

1. in VB. open solution file "D: \ VB.net \ window_client \ window_client.sln", "Create client Windows Forms Program in C/S mode" in case 9-3 of Unit 9 ", after the solution file is opened, select "File> Add project> New Project". The "new project" dialog box appears, in the "project type" List of the dialog box, select "installation and deployment project", select "Installation Wizard" in the "template" list, and enter "D: \ VB.net ", fill in" window_clientsetup_xd "in the project name column, and click" OK ". The Wizard will automatically create source files related to the installer.

2. click OK. The installation wizard dialog box is displayed. You are welcome to use the Installation Project Wizard interface. The installation wizard step is displayed in the title bar of the dialog box, click "Next.

3. Step 2 of the Installation Wizard allows you to select a project type, that is, to determine the location and method in which the file will be installed on the target computer. To deploy a Windows application, select the default option "Create an installer for a Windows application", as shown in Figure 10-18.

4. Select the default option in step 1 and click "Next" to go to step 2 of the Installation Wizard. This step prompts you which project output groups are included in the deployment installation file. In this case, select all output groups, as shown in Figure 10-19.

5. Step 4 of the Installation Wizard. In this step, select the additional files to be added, such as the self-report files, some web pages, and database files. If VB. net, you can click "add" in 10-20 if you cannot include some files to the installation file according to its own rules, in the displayed open file dialog box, select the file to be added.

6. Step 4 of the Installation Wizard. As shown in figure 10-21, this step does not provide user input options, but just confirms all the projects, such as the directory where the installation files are stored, the output group, and the added files. If any problem is found, click "previous" and go back to the relevant interface to reset the settings, if no problem exists, simply click "finish" to create the installation file of the window_client project by using the installation wizard. After completing all the steps of the Installation wizard, you can find that the Solution Explorer has a project file window_clientsetup_xd.

 

Figure 10-18 Dialog Box 2 of the Installation Wizard

Figure 10-19 Dialog Box 3 of the Installation Wizard

Figure 10-20 Dialog Box 4 of the Installation Wizard

Figure 10-21 dialog box 5 of the Installation Wizard

7. in the preceding steps, only the installation project files are generated. To generate executable installation files that can finally be installed and deployed on other computers, you also need to compile the installation project into an executable file or. MSI file. To generate an executable Installation File, right-click the installation project window_clientsetup_xd and choose generate from the shortcut menu, as shown in Figure 10-22. Use the Installation Wizard to generate an executable installation file for the window_client project and store it in the "D: \ VB.net \ window_clientsetup_xd \ debug" folder.

Figure 10-22 generate an executable installation file for the project

 

In case 10-1, case 10-2, and case 10-3, if you select to install a project, seven icons will appear in the shortcut icon bar of solution Resource Manager, choose File System Editor, Registry Editor, file type editor, User Interface Editor, custom operation interface editor, and startup condition editor from left to right. "and" attributes ", 10-27.

 

10.4 run the installer to release the project file

[Case 10-4] installation and release of the project.

This case describes the executable installation file generated in the running case 10-2 and the installation process of releasing the window_client project to other computers.

[Skill Objectives]

Run the installer to release the project file.

[Key Points and steps]

After the installation file is generated in case 10-2, the last step to install and deploy the window_client project is to copy the installation file to another computer and execute the installation file, finally, you can obtain the applications that can run on the target computer.

In the debugdirectory under the "D: \ VB.net \ window_client \ window_clientsetup" folder, a total of 3 files are generated. Among them, setup.exe is the installation file EXE version, window_clientsetup. msi uses the Windows installerservice to develop the installation process. Compared with General Executable File Installation Tools, The setup.exe Installation File is suitable for systems without the Windows Installer Service. setup. INI is an INI file, because it is not used here. INI file operations, so the content of this file is very simple. To ensure smooth installation, you can copy these three files to the target computer through a CD or other mobile storage media, install and deploy the window_client project on the target computer.

Figure 10-23 installation files

1. After saving the file to the target computer, run setup.exe or window_clientsetup. MSI to start the installation process of the application. The installation dialog box is displayed first.

2. Click "Next". The "Select installation folder" dialog box appears. Use the default value in the options of this dialog box and click "Next", as shown in Figure 10-24.

Figure 10-24 "Select installation folder" dialog box

3. After you click "Next" in Figure 10-24, the "Confirm installation" dialog box appears. In this dialog box, click "Next", as shown in Figure 10-25.

Figure 10-25 "Confirm installation" dialog box

4. Click "Next" in Figure 10-25, and the "installing" page appears, as shown in Figure 10-26. After the installation is complete, the "Installation Complete" page appears, indicating that the installation is complete. Click the close button and click Start to point to program. You can see that there is a shortcut "window_client" in the Program Group, as shown in 10-27. Open the user desktop, and there is also the application shortcut "window_client" on the desktop ".

Figure 10-26 "installing"

 

Figure 10-27 program group shortcut "window_client"

1. Run case 10-1 and case 10-3 to generate executable installation files, and release their respective projects to other computers for installation.

2. note: "When the translatewebservice project is released, in the dialog box from figure 10 to 30, enter the "installation folder" as the "translatewebservice" folder, because the client applications reference the WebService of the translatewebservice project, this is equivalent to a fixed website, and the website remains unchanged. Otherwise, the client will not be able to find the website and will not be able to access the Web service.

3. Enter the installation folder in the "Select installation folder" dialog box in Figure 10-30.

Follow the steps 1-5 above to run the Installation File of case 10-1, double-click the shortcut "window_client" of the application on the user desktop, and enter 7 in the first text box of the displayed form, after you click the command button, Seven, 10-28 is displayed in the second text box. This indicates that the WebService Service Application has been correctly deployed (the Installation File in case 10-1 is to be run correctly to deploy WebService ), the client can correctly call the WebService.

Figure 10-28 the client correctly calls the WebService

If you want to uninstall the window_client project installed on the target computer, you only need to run the installation file again. If you run the installation file again, the dialog box 10-29 appears. In the dialog box in Figure 10-29, after you select the "Remove" by "finish" button, the unmount interface shown in 10-30 will appear. After a while, the unmount interface will appear, indicating that the software has been uninstalled. After uninstallation, all folders, start menus, and Desktop shortcuts deployed on the target computer are deleted.

 

Figure 10-29 uninstall installation dialog box

Figure 10-30 uninstall

If you have run the installation file generated in case 10-1 and correctly deployed the WebService and client projects in B/S mode, open IE and enter HTTP in the address bar of IE: // After localhost/browse_clientsetup/webform1.aspx information, the page shown in 9-19 is displayed. Enter 8 in the first text box and click the command button, eight will appear in the second text box.

Exercise area 10

I. Basic Questions

1. The installation process for generating client browser programs in B/S mode is similar to that for generating WebService programs in case 10-1. What are the differences?

2. How can I install and deploy an application project?

3. How many installation files are generated in case 10-1, case 10-2, and case 10-3? What are the functions of these files?

4. How can I create a desktop shortcut and a shortcut in a program group by running the generated installation file?

5. in case 10-1, case 10-2, and case 10-3, if you select to install a project, seven icons will appear in the shortcut icon bar of solution Resource Manager, choose File System Editor, Registry Editor, file type editor, User Interface Editor, custom operation interface editor, and startup condition editor from left to right. "and" attributes ", as shown in 10-30, please operate on the seven icons on the shortcut icon bar and appreciate their functions.

6. Running the generated installation file on the target computer can easily install the project. What should I do if I want to uninstall the installed project?

Ii. Practical questions

Use the "installation and deployment project" to generate the installation files of WebService, browse client browser form program in B/S mode, and Windows application client program in C/S mode; then install and deploy the project on another computer using the generated three installation files. Complete the procedure of case 10-1, case 10-2, case 10-3, and case 10-4.

Iii. Challenges

If you do not run the Installation File of case 10-1, copy the source files of Case 9-1 and Case 9-2 to the corresponding folders of other computers, and enter the corresponding address of the client in the address bar of IE browser (. aspx) How can I correctly call the WebService?

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/mohongmao/archive/2008/11/30/3414397.aspx

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.