From 53b1e7ba048bb692aa1c203ffe7f68be439fbc0c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 18 May 2023 11:04:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E5=B8=83=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PublishSite/PublishForm.Designer.cs | 116 ++++++++------- PublishSite/PublishForm.cs | 210 +++++++++++++++++----------- PublishSite/PublishSite.csproj | 23 +-- 3 files changed, 196 insertions(+), 153 deletions(-) diff --git a/PublishSite/PublishForm.Designer.cs b/PublishSite/PublishForm.Designer.cs index 7acb43b5..b34e1f46 100644 --- a/PublishSite/PublishForm.Designer.cs +++ b/PublishSite/PublishForm.Designer.cs @@ -102,9 +102,9 @@ groupBox1.Controls.Add(rb_test); groupBox1.Controls.Add(rb_local); groupBox1.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point); - groupBox1.Location = new Point(12, 147); + groupBox1.Location = new Point(12, 123); groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(694, 116); + groupBox1.Size = new Size(661, 105); groupBox1.TabIndex = 1; groupBox1.TabStop = false; groupBox1.Text = "环境(服务的操作,备份操作作用的主机)"; @@ -112,7 +112,7 @@ // rb_production // rb_production.AutoSize = true; - rb_production.Location = new Point(434, 53); + rb_production.Location = new Point(434, 48); rb_production.Name = "rb_production"; rb_production.Size = new Size(55, 24); rb_production.TabIndex = 3; @@ -123,7 +123,7 @@ // rb_Verify // rb_Verify.AutoSize = true; - rb_Verify.Location = new Point(300, 53); + rb_Verify.Location = new Point(300, 48); rb_Verify.Name = "rb_Verify"; rb_Verify.Size = new Size(55, 24); rb_Verify.TabIndex = 2; @@ -134,7 +134,7 @@ // rb_test // rb_test.AutoSize = true; - rb_test.Location = new Point(164, 53); + rb_test.Location = new Point(164, 48); rb_test.Name = "rb_test"; rb_test.Size = new Size(55, 24); rb_test.TabIndex = 1; @@ -146,7 +146,7 @@ // rb_local.AutoSize = true; rb_local.Checked = true; - rb_local.Location = new Point(24, 53); + rb_local.Location = new Point(24, 48); rb_local.Name = "rb_local"; rb_local.Size = new Size(55, 24); rb_local.TabIndex = 0; @@ -159,18 +159,18 @@ // groupBox3.Controls.Add(logTBox); groupBox3.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point); - groupBox3.Location = new Point(712, 12); + groupBox3.Location = new Point(679, 13); groupBox3.Name = "groupBox3"; - groupBox3.Size = new Size(621, 1059); + groupBox3.Size = new Size(569, 925); groupBox3.TabIndex = 3; groupBox3.TabStop = false; groupBox3.Text = "日志"; // // logTBox // - logTBox.Location = new Point(23, 21); + logTBox.Location = new Point(6, 21); logTBox.Name = "logTBox"; - logTBox.Size = new Size(577, 1021); + logTBox.Size = new Size(553, 894); logTBox.TabIndex = 1; logTBox.Text = ""; // @@ -179,10 +179,10 @@ tabControl1.Controls.Add(tabPage2); tabControl1.Controls.Add(tabPage1); tabControl1.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point); - tabControl1.Location = new Point(12, 266); + tabControl1.Location = new Point(14, 233); tabControl1.Name = "tabControl1"; tabControl1.SelectedIndex = 0; - tabControl1.Size = new Size(694, 791); + tabControl1.Size = new Size(665, 704); tabControl1.TabIndex = 2; // // tabPage2 @@ -192,7 +192,7 @@ tabPage2.Location = new Point(4, 29); tabPage2.Name = "tabPage2"; tabPage2.Padding = new Padding(3); - tabPage2.Size = new Size(686, 758); + tabPage2.Size = new Size(657, 671); tabPage2.TabIndex = 1; tabPage2.Text = "备份与发布"; tabPage2.UseVisualStyleBackColor = true; @@ -211,27 +211,29 @@ groupBox7.ForeColor = SystemColors.InactiveCaptionText; groupBox7.Location = new Point(3, 6); groupBox7.Name = "groupBox7"; - groupBox7.Size = new Size(677, 280); + groupBox7.Size = new Size(643, 243); groupBox7.TabIndex = 44; groupBox7.TabStop = false; - groupBox7.Text = "后端备份"; + groupBox7.Text = "远程主机后端备份"; // // backExePath // backExePath.Enabled = false; backExePath.Location = new Point(200, 81); backExePath.Name = "backExePath"; - backExePath.Size = new Size(464, 25); + backExePath.Size = new Size(424, 25); backExePath.TabIndex = 5; // // bakConfigSaveBtn // - bakConfigSaveBtn.Location = new Point(124, 194); + bakConfigSaveBtn.BackColor = Color.Beige; + bakConfigSaveBtn.ForeColor = Color.Black; + bakConfigSaveBtn.Location = new Point(124, 183); bakConfigSaveBtn.Name = "bakConfigSaveBtn"; bakConfigSaveBtn.Size = new Size(128, 40); bakConfigSaveBtn.TabIndex = 42; bakConfigSaveBtn.Text = "备份配置保存"; - bakConfigSaveBtn.UseVisualStyleBackColor = true; + bakConfigSaveBtn.UseVisualStyleBackColor = false; bakConfigSaveBtn.Click += bakConfigSaveBtn_Click; // // label3 @@ -245,19 +247,21 @@ // // startBakBtn // - startBakBtn.Location = new Point(378, 194); + startBakBtn.BackColor = Color.Beige; + startBakBtn.ForeColor = Color.Black; + startBakBtn.Location = new Point(368, 183); startBakBtn.Name = "startBakBtn"; startBakBtn.Size = new Size(128, 40); startBakBtn.TabIndex = 6; startBakBtn.Text = "开始备份"; - startBakBtn.UseVisualStyleBackColor = true; + startBakBtn.UseVisualStyleBackColor = false; startBakBtn.Click += startBakBtn_Click; // // backPathTBox // backPathTBox.Location = new Point(200, 131); backPathTBox.Name = "backPathTBox"; - backPathTBox.Size = new Size(464, 25); + backPathTBox.Size = new Size(424, 25); backPathTBox.TabIndex = 1; // // label4 @@ -282,7 +286,7 @@ // bakDbName.Location = new Point(200, 36); bakDbName.Name = "bakDbName"; - bakDbName.Size = new Size(464, 25); + bakDbName.Size = new Size(424, 25); bakDbName.TabIndex = 3; // // groupBox6 @@ -296,26 +300,28 @@ groupBox6.Controls.Add(selectPublishFilePathBtn); groupBox6.Controls.Add(publishFileTBox); groupBox6.Controls.Add(label7); - groupBox6.Location = new Point(3, 292); + groupBox6.Location = new Point(3, 257); groupBox6.Name = "groupBox6"; - groupBox6.Size = new Size(677, 413); + groupBox6.Size = new Size(643, 408); groupBox6.TabIndex = 43; groupBox6.TabStop = false; groupBox6.Text = "上传文件到远程服务器发布"; // // sshNetCorePublishBtn2 // - sshNetCorePublishBtn2.Location = new Point(378, 367); + sshNetCorePublishBtn2.BackColor = Color.Beige; + sshNetCorePublishBtn2.ForeColor = Color.Black; + sshNetCorePublishBtn2.Location = new Point(368, 328); sshNetCorePublishBtn2.Name = "sshNetCorePublishBtn2"; sshNetCorePublishBtn2.Size = new Size(128, 40); sshNetCorePublishBtn2.TabIndex = 52; sshNetCorePublishBtn2.Text = "发布后端"; - sshNetCorePublishBtn2.UseVisualStyleBackColor = true; + sshNetCorePublishBtn2.UseVisualStyleBackColor = false; sshNetCorePublishBtn2.Click += sshNetCorePublishBtn2_Click; // // selectPublishFolderPathBtn // - selectPublishFolderPathBtn.Location = new Point(529, 282); + selectPublishFolderPathBtn.Location = new Point(519, 282); selectPublishFolderPathBtn.Name = "selectPublishFolderPathBtn"; selectPublishFolderPathBtn.Size = new Size(95, 27); selectPublishFolderPathBtn.TabIndex = 51; @@ -334,34 +340,38 @@ // // publishFolderTBox // - publishFolderTBox.Location = new Point(79, 282); + publishFolderTBox.Location = new Point(69, 282); publishFolderTBox.Name = "publishFolderTBox"; publishFolderTBox.Size = new Size(427, 25); publishFolderTBox.TabIndex = 49; // // sshNetCorePublishBtn // - sshNetCorePublishBtn.Location = new Point(378, 166); + sshNetCorePublishBtn.BackColor = Color.Beige; + sshNetCorePublishBtn.ForeColor = Color.Black; + sshNetCorePublishBtn.Location = new Point(368, 166); sshNetCorePublishBtn.Name = "sshNetCorePublishBtn"; sshNetCorePublishBtn.Size = new Size(128, 40); sshNetCorePublishBtn.TabIndex = 48; sshNetCorePublishBtn.Text = "发布后端"; - sshNetCorePublishBtn.UseVisualStyleBackColor = true; + sshNetCorePublishBtn.UseVisualStyleBackColor = false; sshNetCorePublishBtn.Click += sshNetCorePublishBtn_Click; // // sshVuePublishBtn // + sshVuePublishBtn.BackColor = Color.Beige; + sshVuePublishBtn.ForeColor = Color.Black; sshVuePublishBtn.Location = new Point(124, 166); sshVuePublishBtn.Name = "sshVuePublishBtn"; sshVuePublishBtn.Size = new Size(128, 40); sshVuePublishBtn.TabIndex = 47; sshVuePublishBtn.Text = "发布前端"; - sshVuePublishBtn.UseVisualStyleBackColor = true; + sshVuePublishBtn.UseVisualStyleBackColor = false; sshVuePublishBtn.Click += sshVuePublishBtn_Click; // // selectPublishFilePathBtn // - selectPublishFilePathBtn.Location = new Point(529, 94); + selectPublishFilePathBtn.Location = new Point(519, 94); selectPublishFilePathBtn.Name = "selectPublishFilePathBtn"; selectPublishFilePathBtn.Size = new Size(95, 27); selectPublishFilePathBtn.TabIndex = 46; @@ -371,7 +381,7 @@ // // publishFileTBox // - publishFileTBox.Location = new Point(79, 98); + publishFileTBox.Location = new Point(69, 98); publishFileTBox.Name = "publishFileTBox"; publishFileTBox.Size = new Size(427, 25); publishFileTBox.TabIndex = 45; @@ -392,7 +402,7 @@ tabPage1.Location = new Point(4, 29); tabPage1.Name = "tabPage1"; tabPage1.Padding = new Padding(3); - tabPage1.Size = new Size(686, 758); + tabPage1.Size = new Size(657, 671); tabPage1.TabIndex = 0; tabPage1.Text = "服务相关操作"; tabPage1.UseVisualStyleBackColor = true; @@ -415,14 +425,14 @@ groupBox4.Controls.Add(selectPathBtn); groupBox4.Location = new Point(6, 16); groupBox4.Name = "groupBox4"; - groupBox4.Size = new Size(660, 439); + groupBox4.Size = new Size(645, 407); groupBox4.TabIndex = 40; groupBox4.TabStop = false; groupBox4.Text = "服务创建与删除"; // // serviceConfigSaveBtn // - serviceConfigSaveBtn.Location = new Point(141, 348); + serviceConfigSaveBtn.Location = new Point(141, 335); serviceConfigSaveBtn.Name = "serviceConfigSaveBtn"; serviceConfigSaveBtn.Size = new Size(128, 40); serviceConfigSaveBtn.TabIndex = 41; @@ -434,7 +444,7 @@ // servicePortTBox.Location = new Point(155, 220); servicePortTBox.Name = "servicePortTBox"; - servicePortTBox.Size = new Size(366, 25); + servicePortTBox.Size = new Size(353, 25); servicePortTBox.TabIndex = 40; // // label6 @@ -450,7 +460,7 @@ // serviceNameTBox.Location = new Point(154, 52); serviceNameTBox.Name = "serviceNameTBox"; - serviceNameTBox.Size = new Size(366, 25); + serviceNameTBox.Size = new Size(353, 25); serviceNameTBox.TabIndex = 30; // // label10 @@ -464,7 +474,7 @@ // // deleteService_Btn // - deleteService_Btn.Location = new Point(538, 56); + deleteService_Btn.Location = new Point(523, 56); deleteService_Btn.Name = "deleteService_Btn"; deleteService_Btn.Size = new Size(95, 27); deleteService_Btn.TabIndex = 38; @@ -483,7 +493,7 @@ // // createService_Btn // - createService_Btn.Location = new Point(379, 348); + createService_Btn.Location = new Point(379, 335); createService_Btn.Name = "createService_Btn"; createService_Btn.Size = new Size(128, 40); createService_Btn.TabIndex = 37; @@ -495,14 +505,14 @@ // serviceDisplayNameTBox.Location = new Point(155, 111); serviceDisplayNameTBox.Name = "serviceDisplayNameTBox"; - serviceDisplayNameTBox.Size = new Size(366, 25); + serviceDisplayNameTBox.Size = new Size(353, 25); serviceDisplayNameTBox.TabIndex = 31; // // en_TBox // en_TBox.Location = new Point(154, 274); en_TBox.Name = "en_TBox"; - en_TBox.Size = new Size(366, 25); + en_TBox.Size = new Size(353, 25); en_TBox.TabIndex = 36; // // label9 @@ -527,12 +537,12 @@ // exePathTbox.Location = new Point(155, 168); exePathTbox.Name = "exePathTbox"; - exePathTbox.Size = new Size(366, 25); + exePathTbox.Size = new Size(353, 25); exePathTbox.TabIndex = 33; // // selectPathBtn // - selectPathBtn.Location = new Point(538, 165); + selectPathBtn.Location = new Point(523, 165); selectPathBtn.Name = "selectPathBtn"; selectPathBtn.Size = new Size(95, 27); selectPathBtn.TabIndex = 34; @@ -546,9 +556,9 @@ groupBox2.Controls.Add(startServiceBtn); groupBox2.Controls.Add(label2); groupBox2.Controls.Add(startOrStopServiceTbox); - groupBox2.Location = new Point(6, 484); + groupBox2.Location = new Point(6, 430); groupBox2.Name = "groupBox2"; - groupBox2.Size = new Size(660, 232); + groupBox2.Size = new Size(645, 232); groupBox2.TabIndex = 39; groupBox2.TabStop = false; groupBox2.Text = "服务停止与启动"; @@ -596,29 +606,31 @@ groupBox5.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point); groupBox5.Location = new Point(10, 9); groupBox5.Name = "groupBox5"; - groupBox5.Size = new Size(696, 129); + groupBox5.Size = new Size(663, 108); groupBox5.TabIndex = 41; groupBox5.TabStop = false; groupBox5.Text = "测试环境基于备份代码重新发布(感觉自动发布未发布成功,重新发布一下)"; // // netCorePublishBtn // - netCorePublishBtn.Location = new Point(351, 50); + netCorePublishBtn.BackColor = Color.Beige; + netCorePublishBtn.Location = new Point(351, 46); netCorePublishBtn.Name = "netCorePublishBtn"; netCorePublishBtn.Size = new Size(128, 40); netCorePublishBtn.TabIndex = 40; netCorePublishBtn.Text = "后端发布"; - netCorePublishBtn.UseVisualStyleBackColor = true; + netCorePublishBtn.UseVisualStyleBackColor = false; netCorePublishBtn.Click += netCorePublishBtn_Click; // // vuePublishBtn // - vuePublishBtn.Location = new Point(91, 50); + vuePublishBtn.BackColor = Color.Beige; + vuePublishBtn.Location = new Point(91, 46); vuePublishBtn.Name = "vuePublishBtn"; vuePublishBtn.Size = new Size(128, 40); vuePublishBtn.TabIndex = 39; vuePublishBtn.Text = "前端发布"; - vuePublishBtn.UseVisualStyleBackColor = true; + vuePublishBtn.UseVisualStyleBackColor = false; vuePublishBtn.Click += vuePublishBtn_Click; // // openFileDialog1 @@ -633,7 +645,7 @@ // AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1353, 1070); + ClientSize = new Size(1254, 949); Controls.Add(tabControl1); Controls.Add(groupBox5); Controls.Add(groupBox3); diff --git a/PublishSite/PublishForm.cs b/PublishSite/PublishForm.cs index a67095a0..5eb85d84 100644 --- a/PublishSite/PublishForm.cs +++ b/PublishSite/PublishForm.cs @@ -79,6 +79,9 @@ namespace PublishSite jObjectCofig = JObject.Parse(configJson); + + + } //测试 if (rb_test.Checked) @@ -146,6 +149,29 @@ namespace PublishSite #endregion + + #region 按键控制 + if (rb_local.Checked) + { + startBakBtn.Enabled = false; + bakConfigSaveBtn.Enabled = false; + sshVuePublishBtn.Enabled = false; + sshNetCorePublishBtn.Enabled = false; + sshNetCorePublishBtn2.Enabled = false; + selectPublishFilePathBtn.Enabled = false; + selectPublishFolderPathBtn.Enabled = false; + } + else + { + startBakBtn.Enabled = true; + bakConfigSaveBtn.Enabled = true; + sshVuePublishBtn.Enabled = true; + sshNetCorePublishBtn.Enabled = true; + sshNetCorePublishBtn2.Enabled = true; + selectPublishFilePathBtn.Enabled = true; + selectPublishFolderPathBtn.Enabled = true; + } + #endregion } @@ -247,104 +273,105 @@ namespace PublishSite private async void startBakBtn_Click(object sender, EventArgs e) { + if (rb_local.Checked) + { + WinformLog("本地环境不支持备份操作,懒得开发"); + return; + } + await Task.Run(() => { - if (rb_local.Checked) + + + using (var client = new SshClient(Host, UserName, Password)) { - WinformLog("本地环境不支持备份操作,懒得开发"); - return; - } - else - { - using (var client = new SshClient(Host, UserName, Password)) + // 连接到远程服务器 + client.Connect(); + + try { - // 连接到远程服务器 - client.Connect(); + var dbName = bakDbName.Text.Trim(); + var backRootPath = backPathTBox.Text.Trim(); + var serviceName = jObjectCofig["DefaultService"]["ServiceName"].ToString().Trim(); - try + var programPath = backExePath.Text.Trim(); + var programFolder = Path.GetDirectoryName(programPath); + + var dbUser = jObjectCofig["BackUp"]["DBUser"].ToString().Trim(); + var dbPwd = jObjectCofig["BackUp"]["DBPwd"].ToString().Trim(); + + + var backupFolderPath = Path.Combine(backRootPath, DateTime.Now.ToString("yyyyMMdd")); + + //创建文件夹 + WinformLog("准备当日备份文件夹..."); + + var command = client.CreateCommand($"if not exist \"{backupFolderPath}\" mkdir \"{backupFolderPath}\""); + command.Execute(); + if (command.ExitStatus != 0) { - var dbName = bakDbName.Text.Trim(); - var backRootPath = backPathTBox.Text.Trim(); - var serviceName = jObjectCofig["DefaultService"]["ServiceName"].ToString().Trim(); - - var programPath = backExePath.Text.Trim(); - var programFolder = Path.GetDirectoryName(programPath); - - var dbUser = jObjectCofig["BackUp"]["DBUser"].ToString().Trim(); - var dbPwd = jObjectCofig["BackUp"]["DBPwd"].ToString().Trim(); - - - var backupFolderPath = Path.Combine(backRootPath, DateTime.Now.ToString("yyyyMMdd")); - - //创建文件夹 - WinformLog("准备当日备份文件夹..."); - - var command = client.CreateCommand($"if not exist \"{backupFolderPath}\" mkdir \"{backupFolderPath}\""); - command.Execute(); - if (command.ExitStatus != 0) - { - throw new Exception($"Failed to create {backupFolderPath}."); - } - - - //停止服务 - WinformLog($"停止后台服务{serviceName}..."); - - var stopServiceCommand = client.CreateCommand($"sc stop \"{serviceName}\""); - stopServiceCommand.Execute(); - - if (stopServiceCommand.ExitStatus != 0) - { - throw new Exception($"Failed to stop {serviceName}."); - } - - Task.Delay(1000); - //备份后端文件 - - WinformLog($"备份后端文件..."); - string archivePath = $"{backupFolderPath}\\NetCore_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}.zip"; - var compressCommand = client.CreateCommand($"powershell.exe Compress-Archive -Path \"{programFolder}\\*.*\" -DestinationPath \"{archivePath}\" -Force"); - compressCommand.Execute(); - if (compressCommand.ExitStatus != 0) - { - throw new Exception("Failed to compress and move folder contents."); - } - - //启动服务 - WinformLog($"启动后台服务{serviceName}..."); - - var startServiceCommand = client.CreateCommand($"sc start \"{serviceName}\""); - startServiceCommand.Execute(); - - if (startServiceCommand.ExitStatus != 0) - { - throw new Exception($"Failed to start {serviceName}."); - } - - - //备份数据库 - - WinformLog($"开始备份数据库{dbName}..."); - - string databaseBackupPath = $"{backupFolderPath}\\db_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}.bak"; - var sqlcommand = client.CreateCommand($"sqlcmd -S . -U \"{dbUser}\" -P \"{dbPwd}\" -Q \"BACKUP DATABASE [{dbName}] TO DISK='{databaseBackupPath}' WITH INIT\""); - sqlcommand.Execute(); - if (sqlcommand.ExitStatus != 0) - { - throw new Exception("Failed to backup database."); - } - - WinformLog($"备份操作执行结束..."); + throw new Exception($"Failed to create {backupFolderPath}."); } - catch (Exception ex) + + + //停止服务 + WinformLog($"停止后台服务{serviceName}..."); + + var stopServiceCommand = client.CreateCommand($"sc stop \"{serviceName}\""); + stopServiceCommand.Execute(); + + if (stopServiceCommand.ExitStatus != 0) { - - WinformLog($"{ex.Message}", Color.Red); + throw new Exception($"Failed to stop {serviceName}."); } + + Task.Delay(1000); + //备份后端文件 + + WinformLog($"备份后端文件..."); + string archivePath = $"{backupFolderPath}\\NetCore_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}.zip"; + var compressCommand = client.CreateCommand($"powershell.exe Compress-Archive -Path \"{programFolder}\\*.*\" -DestinationPath \"{archivePath}\" -Force"); + compressCommand.Execute(); + if (compressCommand.ExitStatus != 0) + { + throw new Exception("Failed to compress and move folder contents."); + } + + //启动服务 + WinformLog($"启动后台服务{serviceName}..."); + + var startServiceCommand = client.CreateCommand($"sc start \"{serviceName}\""); + startServiceCommand.Execute(); + + if (startServiceCommand.ExitStatus != 0) + { + throw new Exception($"Failed to start {serviceName}."); + } + + + //备份数据库 + + WinformLog($"开始备份数据库{dbName}..."); + + string databaseBackupPath = $"{backupFolderPath}\\db_{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}.bak"; + var sqlcommand = client.CreateCommand($"sqlcmd -S . -U \"{dbUser}\" -P \"{dbPwd}\" -Q \"BACKUP DATABASE [{dbName}] TO DISK='{databaseBackupPath}' WITH INIT\""); + sqlcommand.Execute(); + if (sqlcommand.ExitStatus != 0) + { + throw new Exception("Failed to backup database."); + } + + WinformLog($"备份操作执行结束..."); } + catch (Exception ex) + { + WinformLog($"{ex.Message}", Color.Red); + } } + + }); } @@ -352,6 +379,8 @@ namespace PublishSite #endregion + + #region 服务的创建与删除 @@ -730,6 +759,8 @@ namespace PublishSite private async void sshVuePublishBtn_Click(object sender, EventArgs e) { + + var desTinationFoder = jObjectCofig["BackUp"]["VuePublishFolder"].ToString(); @@ -818,6 +849,8 @@ namespace PublishSite private async void sshNetCorePublishBtn_Click(object sender, EventArgs e) { + + var binPath = jObjectCofig["DefaultService"]["BinPath"].ToString(); var desTinationFoder = Path.GetDirectoryName(binPath); @@ -932,6 +965,13 @@ namespace PublishSite private async void sshNetCorePublishBtn2_Click(object sender, EventArgs e) { + if (string.IsNullOrEmpty(publishFolderTBox.Text) || !File.Exists(publishFolderTBox.Text)) + { + WinformLog($"请选择存在的文件夹才能开始发布", Color.Red); + return; + } + + var binPath = jObjectCofig["DefaultService"]["BinPath"].ToString(); var localSourceFolder = publishFolderTBox.Text; diff --git a/PublishSite/PublishSite.csproj b/PublishSite/PublishSite.csproj index 7f52729b..0c230345 100644 --- a/PublishSite/PublishSite.csproj +++ b/PublishSite/PublishSite.csproj @@ -11,17 +11,16 @@ - - - - - - - + Always true PreserveNewest - + + + Always + true + PreserveNewest + Always true @@ -43,12 +42,4 @@ - - - Always - true - PreserveNewest - - - \ No newline at end of file