Web项目打包过程Word下载.docx
《Web项目打包过程Word下载.docx》由会员分享,可在线阅读,更多相关《Web项目打包过程Word下载.docx(24页珍藏版)》请在冰点文库上搜索。
选择WindowsInstaller最高版本)
(图10)
(图11)
5、选择启动条件(提示:
本机必须装至少为IIS5.1版本)如(图12、13);
(图12)
(图13)
6、添加许可协议(图14、15、16、17、18、19、20、21);
(图14)
(图15)
(图16)
上移到“欢迎使用”下)
(图17)
(图18)
(图19)
(图20)
(图21)
7、设置数据库信息(图14、22、23、24、25、26)
(图22)
上移到“许可协议”下)
(图23)
(图24)
(图25)
设置数据库连接参数信息(提示:
如果没有第四个编辑字段,则设置该字段为隐藏状态)如下
(图26)
8、添加安装类如(图27、28、29、30、31、32)
(图27)
(图28)
(图29)
(图30)
(图31)
(图32)
添加的代码如下:
usingSystem;
usingSystem.Collections;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Configuration.Install;
usingSystem.Linq;
usingSystem.Xml;
usingSystem.Diagnostics;
usingSystem.Data;
usingSystem.Data.SqlClient;
namespaceInstallDB
{
[RunInstaller(true)]
publicpartialclassInstaller:
System.Configuration.Install.Installer
{
publicInstaller()
InitializeComponent();
}
publicoverridevoidInstall(System.Collections.IDictionarystateSaver)
base.Install(stateSaver);
//参数名必须与用户界面的“文本框A”设置的参数必须一致
stringserver=this.Context.Parameters["
server"
];
stringuid=this.Context.Parameters["
uid"
stringpwd=this.Context.Parameters["
pwd"
stringpath=this.Context.Parameters["
targetdir"
stringDataName="
GDKSHDB"
;
//数据库名称
stringconnString="
server="
+server+"
uid="
+uid+"
pwd="
+pwd+"
database="
+DataName;
stringconnStr="
database=master"
stringstrMdf=path+"
fxFrame.mdf"
//如果是文件大于800M,则必须指定目录,不能用path安装目录
stringstrLdf=path+"
fxFrame_log.ldf"
//
UpdateConConfig(connString,path+"
web.config"
);
this.CreateDataBase(connStr,DataName,strMdf,strLdf);
///<
summary>
///附加数据库
/summary>
paramname="
strSql"
>
数据库连接字符串<
/param>
DataName"
数据库名称<
strMdf"
数据文件路径<
strLdf"
日志文件路径<
privatevoidCreateDataBase(stringconnStr,stringDataName,stringstrMdf,stringstrLdf)
Stringstr;
SqlConnectionmyConn=newSqlConnection(connStr);
str="
EXECsp_attach_db@dbname='
"
+DataName+"
'
@filename1='
+strMdf+"
@filename2='
+strLdf+"
SqlCommandmyCommand=newSqlCommand(str,myConn);
myConn.Open();
myCommand.ExecuteNonQuery();
myConn.Close();
myConn.Dispose();
/// <
/// 修改Web项目web.config配置文件的值
param name="
conName"
连接字符串名称<
conString"
连接字符串<
configfilePath"
设定档路径及名称<
publicstaticvoidUpdateConConfig(stringconString,stringconfigfilePath)
XmlDocumentxmlDoc=newXmlDocument();
//读取设定档
xmlDoc.Load(configfilePath);
//取得连接字符串的节点
XmlNodexmlNode=xmlDoc.SelectSingleNode("
configuration/appSettings/add[@key='
Connection'
]"
//修改连接字符串
xmlNode.Attributes["
value"
].InnerText=conString;
//保存
xmlDoc.Save(configfilePath);
}
9、添加安装输出如(图33、34、35、36、37、38、39)
(图33)
(图34)
(图35)
(图36)
(图37)
(图38)
(图39)
指定要传递到安装程序的自定义数据代码如下:
/server=[CUSTOMTEXTA1]/uid=[CUSTOMTEXTA2]/pwd=[CUSTOMTEXTA3]/targetdir="
[TARGETDIR]\"
其中的空格必不可少)
10、配置项目如(图40、41);
(图40)
(图41)
11、重新生成解决方案,然后从WebSetup\Debug目录下拷出安装目录(WebSetup.msi)即可。