コード例 #1
0
        public BootstrapperForm(ClickOnceConfigFile config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config", "config 不能为空。");
            }

            this.config = config;
            InitializeComponent();

            btnOK.Click += delegate(object sender, EventArgs e)
            {
                SaveSettings();
                this.DialogResult = DialogResult.OK;
            };


            radioComponentsLocationDefault.Checked          = false;
            radioComponentsLocationRelative.Checked         = false;
            radioComponentsLocationAbsolute.Checked         = true;
            radioComponentsLocationAbsolute.CheckedChanged += delegate(object sender, EventArgs e)
            {
                cmbBootstrapperComponentsUrl.Enabled = radioComponentsLocationAbsolute.Checked;
                btnBrowse.Enabled = radioComponentsLocationAbsolute.Checked;
            };
        }
コード例 #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (string.IsNullOrEmpty(this.initSettingsFile))
            {
                this.document = null;
            }
            else if (File.Exists(this.initSettingsFile))
            {
                try
                {
                    document = ClickOnceConfigFile.NewDocument(this.initSettingsFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "加载失败," + ex.Message, "提示");
                }
            }
            else
            {
                MessageBox.Show(this, "指定的文件不存在。", "提示");
                this.document = null;
            }


            UpdateUiFromDocument(document);

            UpdateUI();
        }
コード例 #3
0
        public ApplicationUpdateForm(ClickOnceConfigFile config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config", "config 不能为空。");
            }

            this.config = config;
            InitializeComponent();
        }
コード例 #4
0
ファイル: BuildForm.cs プロジェクト: eltonfan/QuickPublish
        void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            progressBar.Visible = false;

            if (hasSuccess(rtbOutput.Text))
            {
                ClickOnceConfigFile config = new ClickOnceConfigFile(this.ClickOnceFile);
                config.PropertyItems.ApplicationRevision++;
                config.WriteXml(this.ClickOnceFile);

                this.Close();
            }
        }
コード例 #5
0
        public PublishOptionsForm(ClickOnceConfigFile config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config", "config 不能为空。");
            }

            this.config = config;
            InitializeComponent();

            btnOK.Click += delegate(object sender, EventArgs e)
            {
                SaveSettings();
                this.DialogResult = DialogResult.OK;
            };
        }
コード例 #6
0
        /// <summary>
        /// UI -> ProjectDocument。
        /// </summary>
        void UpdateUiToDocument(ClickOnceConfigFile config)
        {
            if (config == null)
            {
                return;
            }

            CsProject.PropertyCollection properties = config.PropertyItems;
            //常规
            config.Settings.DistributionPath = txtDistributionPath.Text;
            config.Settings.ExecuteFile      = txtExecuteFile.Text;
            config.Settings.ExecuteFileType  = chkIsCLR.Checked ? ExecuteFileTypes.CLR : ExecuteFileTypes.Win32;
            config.Settings.AssemblyInfoFile = txtAssemblyInfoFile.Text;
            //引导程序集
            properties.AssemblyName = txtAssemblyName.Text.Trim();
            properties.AssemblyOriginatorKeyFile     = txtAssemblyOriginatorKeyFile.Text;
            properties.ManifestCertificateThumbprint = txtManifestCertificateThumbprint.Text;
            properties.ManifestKeyFile = txtManifestKeyFile.Text;

            //发布选项
            properties.PublishUrl = txtPublishUrl.Text;
            properties.InstallUrl = txtInstallUrl.Text;
            properties.Install    = radioInstallEnable.Checked;

            if (chkEnableApplicationRevision.Checked)
            {                                                                    //自动更新
                properties.ApplicationVersion = string.Format("{0}.{1}.{2}.%2a", // %2a = *
                                                              txtApplicationVersionMajor.Text,
                                                              txtApplicationVersionMinor.Text,
                                                              txtApplicationVersionBuild.Text);
            }
            else
            {
                properties.ApplicationVersion = string.Format("{0}.{1}.{2}.{3}",
                                                              txtApplicationVersionMajor.Text,
                                                              txtApplicationVersionMinor.Text,
                                                              txtApplicationVersionBuild.Text,
                                                              numApplicationRevision.Value.ToString());
            }
            properties.ApplicationRevision = (int)numApplicationRevision.Value;

            //其他

            config.RefreshPublishFiles();
        }
コード例 #7
0
        public static ClickOnceConfigFile NewDocument(string fileName)
        {
            try
            {
                string templatePath = Properties.Settings.Default.TemplatePath;
                ClickOnceConfigFile          document   = new ClickOnceConfigFile(Path.Combine(templatePath, "loader.csproj"));
                CsProject.PropertyCollection properties = document.PropertyItems;

                properties.ProjectGuid = Guid.NewGuid().ToString("B").ToUpper();
                document.WriteXml(fileName);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(new ClickOnceConfigFile(fileName));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: eltonfan/QuickPublish
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string settingsFile = "";
            string options      = "";

            if (args.Length > 0)
            {
                settingsFile = args[0];
            }
            if (args.Length > 1)
            {
                options = args[1];
            }

            Form form = null;

            switch (options.Trim().ToLower())
            {
            case "/update":
                string fileName = System.IO.Path.Combine(Application.StartupPath, settingsFile);
                ClickOnceConfigFile document = new ClickOnceConfigFile(fileName);
                document.RefreshPublishFiles();
                //项目文件
                document.WriteXml(document.FileName);
                Console.WriteLine("/update 成功更新。");
                return;

            case "/build":
                form = new BuildForm(settingsFile);
                break;

            default:
                form = new MainForm(settingsFile);
                break;
            }
            Application.Run(form);
        }
コード例 #9
0
        void LoadOptionsFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "打开配置文件";
            ofd.Filter = "ClickOnce 发布配置文件(*.xml)|*.xml|C# 项目文件(*.csproj)|*.csproj";
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    document = new ClickOnceConfigFile(ofd.FileName);
                    UpdateUiFromDocument(document);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "加载失败," + ex.Message, "提示");
                    return;
                }
            }

            UpdateUI();
        }
コード例 #10
0
        /// <summary>
        /// 新建配置文件。
        /// </summary>
        void NewOptionsFile()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title  = "新建配置文件";
            sfd.Filter = "ClickOnce 发布配置文件(*.xml)|*.xml|C# 项目文件(*.csproj)|*.csproj";
            if (sfd.ShowDialog(this) == DialogResult.OK)
            {
                try
                {
                    document = ClickOnceConfigFile.NewDocument(sfd.FileName);
                    UpdateUiFromDocument(document);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "加载失败," + ex.Message, "提示");
                    return;
                }
            }

            UpdateUI();
        }
コード例 #11
0
        void Publish(BackgroundWorker bw, string settingsFile)
        {
            ClickOnceConfigFile config = new ClickOnceConfigFile(settingsFile);
            string publishPath         = config.PropertyItems.PublishUrl;

            bw.ReportProgress(5, "初始化临时目录...");
            string templatePath = Properties.Settings.Default.TemplatePath;
            string projectPath  = Path.Combine(publishPath, Guid.NewGuid().ToString("N").ToLower());

            if (!Directory.Exists(projectPath))
            {
                Directory.CreateDirectory(projectPath);
            }

            bw.ReportProgress(5, "生成C#项目...");
            string projectFile = Path.Combine(projectPath, "loader.csproj");

            config.SaveAsCsProject(projectFile);

            bw.ReportProgress(5, string.Format("正在编译{0}...", projectFile));
            CmdMSBuild(projectFile);

            //复制
            bw.ReportProgress(5, string.Format("复制到{0}...", publishPath));
            string appPublish = Path.Combine(projectPath, @"bin\Release\app.publish");

            if (Directory.Exists(appPublish))
            {
                Common.MoveDirectory(appPublish, publishPath, null);
            }

            bw.ReportProgress(5, string.Format("清理临时目录{0}...", publishPath));
            Directory.Delete(projectPath, true);

            bw.ReportProgress(100, "操作完成。");
        }
コード例 #12
0
        /// <summary>
        /// ProjectDocument -> UI。
        /// </summary>
        /// <param name="basePath"></param>
        void UpdateUiFromDocument(ClickOnceConfigFile config)
        {
            if (config == null)
            {
                tabControl1.Enabled = false;
                //常规
                txtDistributionPath.Text = "";
                txtExecuteFile.Text      = "";
                chkIsCLR.Checked         = false;
                txtAssemblyInfoFile.Text = "";
                //引导程序集
                txtAssemblyName.Text = "";
                txtAssemblyOriginatorKeyFile.Text     = "";
                txtManifestCertificateThumbprint.Text = "";
                txtManifestKeyFile.Text = "";

                //发布选项
                txtPublishUrl.Text          = "";
                txtInstallUrl.Text          = "";
                radioInstallDisable.Checked = false;
                radioInstallEnable.Checked  = true;

                txtApplicationVersionMajor.Text = "";
                txtApplicationVersionMinor.Text = "";
                txtApplicationVersionBuild.Text = "";
                numApplicationRevision.Value    = 0;

                chkEnableApplicationRevision.Checked = false;

                //其他
            }
            else
            {
                tabControl1.Enabled = true;
                string basePath = config.BasePath;

                CsProject.PropertyCollection properties = config.PropertyItems;
                //常规
                txtDistributionPath.Text = config.Settings.DistributionPath;
                txtExecuteFile.Text      = config.Settings.ExecuteFile;
                chkIsCLR.Checked         = (config.Settings.ExecuteFileType == ExecuteFileTypes.CLR);
                txtAssemblyInfoFile.Text = config.Settings.AssemblyInfoFile;

                //引导程序集
                txtAssemblyName.Text = properties.AssemblyName;
                txtAssemblyOriginatorKeyFile.Text     = string.IsNullOrEmpty(properties.AssemblyOriginatorKeyFile) ? "" : Sense.Utils.IO.Path.GetAbsolutePath(basePath, properties.AssemblyOriginatorKeyFile);
                txtManifestCertificateThumbprint.Text = properties.ManifestCertificateThumbprint;
                txtManifestKeyFile.Text = string.IsNullOrEmpty(properties.ManifestKeyFile) ? "" : Sense.Utils.IO.Path.GetAbsolutePath(basePath, properties.ManifestKeyFile);

                //发布选项
                txtPublishUrl.Text          = properties.PublishUrl;
                txtInstallUrl.Text          = properties.InstallUrl;
                radioInstallDisable.Checked = !properties.Install;
                radioInstallEnable.Checked  = properties.Install;

                string[] applicationVersionParts = properties.ApplicationVersion.Split('.');
                if (applicationVersionParts.Length >= 4)
                {
                    txtApplicationVersionMajor.Text = applicationVersionParts[0];
                    txtApplicationVersionMinor.Text = applicationVersionParts[1];
                    txtApplicationVersionBuild.Text = applicationVersionParts[2];
                    numApplicationRevision.Value    = properties.ApplicationRevision;

                    chkEnableApplicationRevision.Checked = (applicationVersionParts[3].Trim() == "*" ||
                                                            applicationVersionParts[3].Trim().ToLower() == "%2a");
                }

                //其他
            }
        }
コード例 #13
0
        /// <summary>
        /// 按配置生成保存为C#项目。
        /// </summary>
        /// <param name="filename"></param>
        public static void SaveAsCsProject(string configFile, string projectFile)
        {
            ClickOnceConfigFile config = new ClickOnceConfigFile(configFile);

            config.SaveAsCsProject(projectFile);
        }