街頭莮炷角 发表于 2014-8-25 08:46:19

安装类写好代码后安装程序老提示无压缩文件

3)安装并复制文件         复制文件的操作在OnBeforeInstall方法中就已经完成,在该方法中可以替换数据库连接字符串操作等。
protected override void OnBeforeInstall(IDictionary savedState)
      {
            if (ExistSqlServerService())
            {
                if (IsExistSitePort())
                {
                  MessageBox.Show("站点端口号重复", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  return;
                }
                if (IsExistSiteName(Context.Parameters["sitename"].ToString()))
                {
                  MessageBox.Show("站点名称重复", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  return;
                }
                base.OnBeforeInstall(savedState);

                unRAR("Message.rar"); //解压文件
                unRAR("MoreUpload.rar");
                /*
               * 设置webconfig连接字符串
               */
                string webconfigpath = Path.Combine(this.Context.Parameters["installdir"].ToString(), "Web.config");
                string webcofnigstring = File.ReadAllText(webconfigpath).Replace("#constring#", GetConnectionString(Context.Parameters["dbname"].ToString()));
                webcofnigstring = webcofnigstring.Replace("#siteport#", Context.Parameters["siteport"].ToString());
                webcofnigstring = webcofnigstring.Replace("#comConn#", "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" + Context.Parameters["user"].ToString() + ";Password=" + Context.Parameters["pwd"].ToString() + ";Initial Catalog=" + Context.Parameters["dbname"].ToString() + ";Data Source=" + Context.Parameters["server"].ToString());
                File.WriteAllText(webconfigpath, webcofnigstring);

                ////安装IIS
                //if (string.Empty == GetIISVerstion())
                //{
                //    IISInstall(this.Context.Parameters["installdir"].ToString() + "IIS6.0_XPSP3", this.Context.Parameters["installdir"].ToString() + "iis.txt");
                //}

            }
            else
            {
                MessageBox.Show("检测到您的电脑没有安装SQL SERVER,无法继续安装此产品", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Rollback(savedState);
            }

      }
      上面代码中解压了两个文件,主要是在安装完创建站点时还需要创建虚拟目录。之所以要先压缩放到WEB项目里,是因为生成安装程序时会检测项目的生成是否成功(是否可以不让它检测成功呢? 还不清楚),一般只要我们把发布好的项目COPY到新建项目下就可以,但是独立的项目文件夹有自己独立的bin目录和webconfig文件,是不能混合在一起生成成功的,但是又需要一次完全安装,那么可以先压缩做为WEB项目下的文件,待复制完后再解压。----------------------------------------------------------------------------------------------------------------红色这句话难道要自己添加压缩包吗?

街頭莮炷角 发表于 2014-8-25 08:50:10

http://www.ibcibc.com/forum.php?mod=image&aid=505&size=300x300&key=6f6c27f3d997eb8d&nocache=yes&type=fixnone
笑脸是;p   变成笑脸了

songyusb 发表于 2014-8-25 09:42:05

没弄过 顶一下

vvdsdsdf 发表于 2014-8-25 09:43:29

看着好高端的样子

ibcadmin 发表于 2014-8-25 09:45:39

用这个innosetup打包工具试试,现在都是直接打包 哪有人还写这个类

街頭莮炷角 发表于 2014-8-25 10:08:34

ibcadmin 发表于 2014-8-25 09:45
用这个innosetup打包工具试试,现在都是直接打包 哪有人还写这个类

我的是Web程序嘛所以想让他自动创建IIS网站但是有错误
页: [1]
查看完整版本: 安装类写好代码后安装程序老提示无压缩文件