gacutil -u "{INSTALL_PATH}\DevExpress.Data.v11.1"
mkdir %windir%\assembly\GAC_MSIL\DevExpress.Data.v11.1\11.1.6.0__b88d1754d700e49a
copy "{INSTALL_PATH}\DevExpress.Data.v11.1.dll" %windir%\assembly\GAC_MSIL\DevExpress.Data.v11.1\11.1.6.0__b88d1754d700e49a
gacutil -u "{INSTALL_PATH}\DevExpress.Utils.v11.1"
mkdir %windir%\assembly\GAC_MSIL\DevExpress.Utils.v11.1\11.1.6.0__b88d1754d700e49a
copy "{INSTALL_PATH}\DevExpress.Utils.v11.1.dll" %windir%\assembly\GAC_MSIL\DevExpress.Utils.v11.1\11.1.6.0__b88d1754d700e49a
gacutil -u "{INSTALL_PATH}\DevExpress.CodeRush.Common"
mkdir %windir%\assembly\GAC_MSIL\DevExpress.CodeRush.Common\11.1.6.0__35c9f04b7764aa3d
copy "{INSTALL_PATH}\DevExpress.CodeRush.Common.dll" %windir%\assembly\GAC_MSIL\DevExpress.CodeRush.Common\11.1.6.0__35c9f04b7764aa3d
REM copy "{INSTALL_PATH}\DevExpress.CodeRush.Common.dll" "C:\Program Files\DevExpress 2011.1\IDETools\System\DXCore\BIN\DevExpress.CodeRush.Common.dll"if "[%ProgramFiles(x86)%]" == "[]" (copy "{INSTALL_PATH}\DevExpress.CodeRush.Common.dll" "%ProgramFiles%\DevExpress 2011.1\IDETools\System\DXCore\BIN\DevExpress.CodeRush.Common.dll") else (copy "{INSTALL_PATH}\DevExpress.CodeRush.Common.dll" "%ProgramFiles(x86)%\DevExpress 2011.1\IDETools\System\DXCore\BIN\DevExpress.CodeRush.Common.dll")echo 'OK'pause2、创建一个安装包后,并增加一个自定义安装项目,命名为InstallerAction项目,然后创建一个“安装程序类”,如下所示项目工程如下: 3)然后我们修改“安装程序类”的代码,覆盖Install函数,主要是用来替换Register.bat批处理文件的路径变量"{INSTALL_PATH}",如下代码所示 [RunInstaller(true)]
publicpartialclass InstallAction : Installer{public InstallAction(){InitializeComponent()}publicoverridevoid Install(IDictionary stateSaver){base.Install(stateSaver)try {string physicalRoot = this.Context.Parameters["targetdir"]// 安装物理路径try {
//由于执行Register.bat文件的时候,gacutil.exe会以System目录作为起始目录,
//因此在Bat文件中设置一个参数,安装的时候替换为具体的目录string Register = Path.Combine(physicalRoot, "Register.bat")
ReplaceName(Register, "{INSTALL_PATH}", physicalRoot)}catch { }string registerFile = Path.Combine(physicalRoot, "Register.bat")
RunDos(registerFile, "", false)}catch (Exception ex){WriteLog(ex.ToString())}}///<summary>/// 在运行脚本之前把脚本中的指定名称替换成新的名词
///</summary>///<param name="filePath">脚本文件名</param>///<param name="oldDBName">原有的名称</param>///<param name="newDBName">新的名称</param>privatevoid ReplaceName(string filePath, string oldName, string newName){if (newName.CompareTo(oldName) != 0){string fileText = string.Empty
using (StreamReader streamReader = new StreamReader(filePath, Encoding.Default)){fileText = streamReader.ReadToEnd()
fileText = fileText.Replace(oldName, newName)}using (StreamWriter streamWriter = new StreamWriter(filePath, false, Encoding.Default)){streamWriter.Write(fileText)}}}///<summary>/// 后台执行DOS文件
///</summary>///<param name="fileName">文件名(包含路径)</param>///<param name="argument">运行参数</param>///<param name="hidden">是否隐藏窗口</param>privatevoid RunDos(string fileName, string argument, bool hidden){Process process = new Process()
process.EnableRaisingEvents = false
process.StartInfo.FileName = string.Format("\"{0}\"", fileName)
process.StartInfo.Arguments = argument
if (hidden){process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden}else {process.StartInfo.WindowStyle = ProcessWindowStyle.Normal}process.Start()
}4、接着在安装包的自定义安装视图中,把刚才自定义安装项目关联到安装包中,如下所示。并修改主输出来自InstallAction的属性项目如下所示5、编译运行程序,我们发现DOS运行的效果如下所示,说明DOS命令正常运行,并复制了文件。6、运行程序,DevExpress界面正常出来,并没有d出额外的窗体,这真是我们需要的,示例界面如下所示。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)