In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use code to achieve ASP.NET installation and deployment, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Introduction to adding files for ASP.NET installation and deployment code implementation:
1. Add the script file db.sql generated by SQL Server to the Test Installer project
two。 Add the installation file LisenceFile.rtf to the "Test Installer" project
3. In the user interface editor, select the license agreement and set the LisenceFile property to the LisenceFile.rtf file
The following ASP.NET installation deployment code implementation is the most important part of the overall deployment
Add code to the installer class, dbcustomaction.vb class
Imports System.ComponentModel imports System.Configuration.Install imports System.IO imports System.Reflection < runinstaller (true) > Public Class DBCustomActionClass DBCustomAction inherits System.Configuration.Install.Installer # region "Code generated by the component designer" public Sub New () Sub New () mybase.new () 'this call is a required initializecomponent () for the component designer' add any initialization end Sub 'Installer override dispose after the InitializeComponent () call to clean up the component list. Protected Overloads Overrides Sub Dispose () Sub Dispose (ByVal disposing As Boolean) if disposing Then if Not (components Is Nothing) Then components.dispose () end If end If mybase.dispose (disposing) end Sub private components As System.ComponentModel.IContainer < system.diagnostics.debuggerstepthrough () > Private Sub InitializeComponent () Sub InitializeComponent () end Sub # end Region 'execute sql statement private Sub ExecuteSql () Sub ExecuteSql (ByVal conn As String, ByVal DatabaseName As String ByVal Sql As String) dim mySqlConnection As New SqlClient.SqlConnection (conn) dim Command As New SqlClient.SqlCommand (Sql MySqlConnection) command.connection.open () command.connection.changedatabase (databasename) try command.executenonquery () finally 'close Connection command.connection.close () end Try end Sub public Overrides Sub Install () Sub Install (ByVal stateSaver As System.Collections.IDictionary) MyBase.Install (stateSaver)'-ASP.NET installation and deployment code to build the database-try dim connStr As String = String.Format ("data source= {0}) User id= {1}; password= {2}; persist security info=false Packet size=4096 ", Me.Context.Parameters.Item (" server "), Me.Context.Parameters.Item (" user "), Me.Context.Parameters.Item (" pwd ") 'create a database executesql (connstr," master ") based on the entered database name "CREATE DATABASE" + Me.Context.Parameters.Item ("dbname") 'ASP.NET installation and deployment code implementation calls osql execution script dim sqlProcess As New System.Diagnostics.Process sqlprocess.startinfo.filename = "osql.exe" sqlprocess.startinfo.arguments = String.Format ("- U {0}-P {1}-d {2}-I {3} db.sql", Me.Context.Parameters.Item ("user"), Me.Context.Parameters.Item ("pwd") Me.Context.Parameters.Item ("dbname"), Me.Context.Parameters.Item ("targetdir") sqlprocess.startinfo.windowstyle = ProcessWindowStyle.Hidden sqlprocess.start () sqlprocess.waitforexit () 'waiting for sqlprocess.close ()' ASP.NET installation and deployment code to implement the deletion script file dim sqlFileInfo As New System.IO.FileInfo (String.Format ("{0} db.sql") Me.Context.Parameters.Item ("targetdir")) if sqlFileInfo.Exists Then sqlfileinfo.delete () end If catch ex As Exception throw ex end Try'- ASP.NET installation and deployment code implements writing the connection string to Web.config-- try dim FileInfo As System.IO.FileInfo = New System.IO.FileInfo ("targetdir") & "\ web.config") if Not FileInfo.Exists Then Throw New InstallException ("configuration file not found") end If 'instantiate xml document dim XmlDocument As New System.Xml.XmlDocument xmldocument.load (fileinfo.fullname)' found node dim Node As System.Xml.XmlNode dim FoundIt As Boolean = False for Each Node In XmlDocument.Item ("configuration") in appsettings. Item ("appSettings") if Node.Name = "add" Then if Node.Attributes.GetNamedItem ("key"). Value = "connString" The Then 'ASP.NET installation deployment code implementation writes the connection string node.attributes.getnameditem ("value"). Value = String. Format ("Persist Security Info=False;Data Source= {0}; Initial Catalog= {1}; User ID= {2}; Password= {3}; Packet Size=4096;Pooling=true;Max Pool Size=100) Min Pool Size=1 ", _ me.context.parameters.item (" server "), Me.Context.Parameters.Item (" dbname "), Me.Context.Parameters.Item (" user ") Me.Context.Parameters.Item ("pwd") foundit = True end If end If next Node if Not FoundIt Then throw New InstallException ("web.Config file does not contain connString connection string settings") end If xmldocument.save (fileinfo.fullname) catch ex As Exception throw ex end Try end Sub end Class
What is a bit difficult is the Process class, which invokes the osql.exe program to execute the sql statement osql-Ujingliujue Pjigui.
The modification code of web.config is implemented using the syntax of xml. It's not hard to understand.
* compile and generate! As shown in the figure:
Installation interface: as shown in the figure
After reading the above, have you mastered how to implement ASP.NET installation and deployment in code? 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.