Create a. NET platform Web project Installation File

Source: Internet
Author: User

Recently, I developed a WEB project with C #. Finally, the product was coming online soon. I felt like something was nearly done. It was inconvenient to use it by throwing a bunch of folders, you also need to impose operations such as database creation on the user, so you decide to make an installation file in one step.

For me who first came into contact with the C # or Microsoft series, I had no clue at first. How should I install it? How does one operate IIS? How to complete database initialization? How to modify the configuration file? After searching for information for half a day on the internet, I finally made the complete installation package. Below we will summarize some problems encountered in the production process and process:

1. Add a web installation project under the project. We recommend that you add the project directly. The advantage is that you can directly introduce the developed web project as the project output. I even tried to open a separate installation project. The result is that all files are manually added one by one according to the project file structure. After the product is updated, you also need to modify the installation project, it causes a lot of trouble. When naming a project, you also need to note that I randomly named an installation name. As a result, the default website name during installation is always the same as the project name, i'm not sure whether VS is the same as I did. Therefore, if you need the default website name to be consistent with your product name, the project name should be the same as the product name.

2. Set the "Install Database" page, right-click the "install project" page, and choose "View"> "User Interface". Add A text box (A) under the "Start" menu. The four text boxes are provided, which is exactly the same as the database installation requirements, here, you need to enter the database server address, the name of the database to be installed, the username and password with the database creation permission, and the name of each field will be used for subsequent database installation.

3. Set the license agreement user interface. This is relatively simple. Copy a license agreement online and save it as an rtf file. After the project is introduced, add a license agreement dialog box and link it to the file.

4. Add a database installation class and add a new class library directly under the project. The language is indifferent. Here I select C # class library and then add an installation class under this project, the database is created in the override Install method, which is relatively simple for database execution. Since new installation projects usually require the introduction of SQL files or database backup files, I was stuck here for a long time. I directly dragged the SQL files into the project and then wrote the code, finally, I always indicated that the SQL file could not be found. The final reason was that I did not set the SQL file generation operation as an embedded resource. You need to modify the configuration file or directly in this class. You need to obtain the current installation path, get the configuration file, and modify the parameters in the configuration file. The retrieval method is the same as obtaining database Parameters: Context. Parameters ["name"]. ToString (). The name is the name of the parameter you want to obtain, that is, the name 1 set in the next step.

5. Add the database installation Class Library output to the installation project, right-click the installation project, view-custom operations, and right-click the installation menu to add a new custom operation, select the added database installation class library, select the custom operation, and set the CustomActionData attribute. The format is/name 1 = [name 2]. name 1 is the string for you to obtain this value. Name 2 is the name of the field in step 2, and VS also provides several built-in variable names, such as TARGETDIR, all the online materials are written differently from the previous one, but I always report errors in my project according to the online writing method. Finally, the rogue was written the same way as the previous one, and it actually passed ~ Is VS2010 a new change?

6. Set the system as required. You must add the environment required for running your project, as shown in. net Component, installer, etc. Note that there is no such component in VS2010. select net2.0 if you only need. net2.0 is a prerequisite for the system. You can copy the DotNetFX folder on the machine with VS2008 installed to C: \ Program Files \ Microsoft SDKs \ Windows \ v7.0A \ Bootstrapper \ Packages in the price folder, or you can directly download this component to this folder.

7. Set system properties. The final operation is to set various miscellaneous and introduce the main output and content files of the web project. If you need to add the source files of the web project, set some log images, some text instructions for installation, and so on. I will not elaborate on it here, and then generate it directly.

Okay, I finally finished writing. I wrote a blog post for the first time. The text skills are too bad. Don't mind the readers. It's very easy to write. I will try again later.

    

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.