From 4724e96efebca3a77905fb9035d530d66ee7d00d Mon Sep 17 00:00:00 2001 From: ZhaoLei Date: Tue, 29 Oct 2024 12:46:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=9C=A8=E5=90=84?= =?UTF-8?q?=E4=B8=AA=E6=AD=A5=E9=AA=A4=E5=89=8D=E5=90=8E=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c# 异步任务里面的异常,不会在异步之外被捕获。 ``` try { Task.Run(()=>{ throw new Exception() //此异常不会被捕获 ) }; catch(Exception ex) { //将不会捕获异常 } --- Server/Common/Config.cs | 33 +++++ Server/Common/ConnectPipeline.cs | 5 +- Server/Common/Message.cs | 2 +- Server/LocalServer/LocalSyncServer.cs | 83 ++++++++++++- .../Properties/launchSettings.json | 2 +- Server/LocalServer/StateHelper.cs | 18 ++- .../PublishProfiles/FolderProfile.pubxml | 17 +++ .../PublishProfiles/FolderProfile.pubxml.user | 11 ++ Server/RemoteServer/RemoteServer.csproj.user | 1 + Server/RemoteServer/RemoteSyncServer.cs | 74 ++++++++++- Server/RemoteServer/StateHelper.cs | 23 +++- Server/ServerTest/PipeSeed.cs | 30 +++++ Server/ServerTest/PipeTest.cs | 18 ++- Tool/JsScript/release.js | 116 +++++++++--------- 14 files changed, 357 insertions(+), 76 deletions(-) create mode 100644 Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml create mode 100644 Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml.user diff --git a/Server/Common/Config.cs b/Server/Common/Config.cs index 95f5a7c..7e1a460 100644 --- a/Server/Common/Config.cs +++ b/Server/Common/Config.cs @@ -1,5 +1,33 @@ namespace Common; +public class ExecProcess +{ + /// + /// 步骤 + /// + public SyncProcessStep Step { get; set; } + + /// + /// A after B before + /// + public required string StepBeforeOrAfter { get; set; } + + /// + /// L Local S Server + /// + public required string ExecInLocalOrServer { get; set; } + + /// + /// 执行的应用程序名称 + /// + public required string FileName { get; set; } + + /// + /// 执行的应用程序参数 + /// + public required string Argumnets { get; set; } +} + public class DirFileConfig { /// @@ -127,4 +155,9 @@ public class Config /// 同步的文件夹配置 /// public required List DirFileConfigs { get; set; } + + /// + /// 按照步骤执行应用程序扩展列表 + /// + public required List ExecProcesses { get; set; } } diff --git a/Server/Common/ConnectPipeline.cs b/Server/Common/ConnectPipeline.cs index 7c3626b..9b41b35 100644 --- a/Server/Common/ConnectPipeline.cs +++ b/Server/Common/ConnectPipeline.cs @@ -6,7 +6,6 @@ namespace Common; public abstract class AbsPipeLine(bool isAES) { - /// /// pipeLine工作函数,生效期间永久阻塞 /// @@ -18,6 +17,7 @@ public abstract class AbsPipeLine(bool isAES) { return true; }; + /// /// 监听pipeline 消息,由Work 函数调用 /// @@ -48,7 +48,6 @@ public abstract class AbsPipeLine(bool isAES) /// 上传完成时返回/ public abstract Task UploadFile(string url, string filePath, Func progressCb); - /// /// 管道消息是否使用AES加密 /// @@ -147,7 +146,7 @@ public class WebSocPipeLine(TSocket socket, bool isAES) : AbsPipeLine(i new SyncMsg { Type = SyncMsgType.Error, - Step = SyncProcessStep.CloseError, + Step = SyncProcessStep.Close, Body = CloseReason ?? "" } ); diff --git a/Server/Common/Message.cs b/Server/Common/Message.cs index a7f9b9a..9c0c93b 100644 --- a/Server/Common/Message.cs +++ b/Server/Common/Message.cs @@ -16,7 +16,7 @@ public enum SyncProcessStep PackSqlServer = 4, UploadAndUnpack = 5, Publish = 6, - CloseError = 7 + Close = 7 } public class SyncMsg diff --git a/Server/LocalServer/LocalSyncServer.cs b/Server/LocalServer/LocalSyncServer.cs index bdf9011..496f31a 100644 --- a/Server/LocalServer/LocalSyncServer.cs +++ b/Server/LocalServer/LocalSyncServer.cs @@ -1,3 +1,5 @@ +using System.Diagnostics; +using System.IO.Pipelines; using System.Xml.Linq; using Common; @@ -8,6 +10,7 @@ public class LocalSyncServer #pragma warning disable CA2211 // Non-constant fields should not be visible public static string TempRootFile = "C:/TempPack"; public static string SqlPackageAbPath = "sqlpackage"; + // 使用msdeploy 将会打包当前可运行的内容,它很有可能不包含最新的构建 //public static string MsdeployAbPath = "msdeploy"; @@ -15,16 +18,88 @@ public class LocalSyncServer //使用msbuild 会缺少.net frame的运行环境 bin\roslyn 里面的内容,第一次需要人为复制一下,后面就就好了。 public static string MSBuildAbPath = "MSBuild"; #pragma warning restore CA2211 // Non-constant fields should not be visible - + /// /// 连接状态,流程管理,LocalPipe 和 remotePipe 也在此处交换信息 /// private StateHelpBase StateHelper; - public void SetStateHelper(StateHelpBase helper) { - StateHelper = helper; + try + { + StateHelper = helper; + if (SyncConfig != null) + { + var LastExec = NotNullSyncConfig.ExecProcesses.Find(x => + { + return x.StepBeforeOrAfter == "A" + && x.Step == (helper.Step - 1) + && x.ExecInLocalOrServer == "L"; + }); + ExecProcess(LastExec); + var CurrentExec = NotNullSyncConfig.ExecProcesses.Find(x => + { + return x.StepBeforeOrAfter == "B" + && x.Step == helper.Step + && x.ExecInLocalOrServer == "L"; + }); + ExecProcess(CurrentExec); + } + } + catch (Exception ex) + { + Close(ex.Message); + } + } + + public void ExecProcess(ExecProcess? ep) + { + if (ep != null) + { + ProcessStartInfo startInfo = + new() + { + StandardOutputEncoding = System.Text.Encoding.UTF8, + Arguments = ep.Argumnets, + FileName = ep.FileName, // The command to execute (can be any command line tool) + // The arguments to pass to the command (e.g., list directory contents) + RedirectStandardOutput = true, // Redirect the standard output to a string + UseShellExecute = false, // Do not use the shell to execute the command + CreateNoWindow = true // Do not create a new window for the command + }; + using Process process = new() { StartInfo = startInfo }; + // Start the process + process.Start(); + + // Read the output from the process + string output = process.StandardOutput.ReadToEnd(); + + // Wait for the process to exit + process.WaitForExit(); + + if (process.ExitCode == 0) + { + LocalPipe + .SendMsg( + StateHelper.CreateMsg( + $"{ep.Step}-{ep.StepBeforeOrAfter}-{ep.ExecInLocalOrServer}-{ep.FileName} {ep.Argumnets} 执行成功!" + ) + ) + .Wait(); + } + else + { + LocalPipe + .SendMsg( + StateHelper.CreateMsg( + $"{ep.Step}-{ep.StepBeforeOrAfter}-{ep.ExecInLocalOrServer}-{ep.FileName} {ep.Argumnets} 失败 {output}!" + ) + ) + .Wait(); + throw new Exception("错误,信息参考上一条消息!"); + } + } } /// @@ -103,7 +178,7 @@ public class LocalSyncServer public readonly AbsPipeLine LocalPipe; /// - /// local server 和 remote server 的连接,它有加密 + /// local server 和 remote server 的连接,它有加密 /// public readonly AbsPipeLine RemotePipe; diff --git a/Server/LocalServer/Properties/launchSettings.json b/Server/LocalServer/Properties/launchSettings.json index 8b5cb2f..fe91e70 100644 --- a/Server/LocalServer/Properties/launchSettings.json +++ b/Server/LocalServer/Properties/launchSettings.json @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5014", + "applicationUrl": "http://localhost:6818", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Server/LocalServer/StateHelper.cs b/Server/LocalServer/StateHelper.cs index e6049ce..0bc1f49 100644 --- a/Server/LocalServer/StateHelper.cs +++ b/Server/LocalServer/StateHelper.cs @@ -40,7 +40,7 @@ public abstract class StateHelpBase( var syncMsg = JsonSerializer.Deserialize(msg) ?? throw new NullReferenceException("msg is null"); - if (syncMsg.Step != Step) + if (syncMsg.Step != Step && syncMsg.Step != SyncProcessStep.Close) { throw new Exception("Sync step error!"); } @@ -55,7 +55,7 @@ public abstract class StateHelpBase( var syncMsg = JsonSerializer.Deserialize(msg) ?? throw new NullReferenceException("msg is null"); - if (syncMsg.Step != Step) + if (syncMsg.Step != Step && syncMsg.Step != SyncProcessStep.Close) { throw new Exception("Sync step error!"); } @@ -416,7 +416,7 @@ public class FinallyPublishHelper(LocalSyncServer context) { protected override void HandleLocalMsg(SyncMsg msg) { - throw new NotImplementedException(); + //throw new NotImplementedException(); } /// @@ -425,6 +425,18 @@ public class FinallyPublishHelper(LocalSyncServer context) /// protected override void HandleRemoteMsg(SyncMsg msg) { + if (msg.Body == "发布完成!") + { + Context.SetStateHelper(new NormalCloseHelper(Context)); + } Context.LocalPipe.SendMsg(msg).Wait(); } } + +public class NormalCloseHelper(LocalSyncServer context) + : StateHelpBase(context, SyncProcessStep.Close) +{ + protected override void HandleRemoteMsg(SyncMsg msg) { } + + protected override void HandleLocalMsg(SyncMsg msg) { } +} diff --git a/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml b/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..4583d5d --- /dev/null +++ b/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,17 @@ + + + + + false + false + true + Release + Any CPU + FileSystem + bin\Release\net8.0\publish\ + FileSystem + <_TargetId>Folder + + \ No newline at end of file diff --git a/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml.user b/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..072b0c4 --- /dev/null +++ b/Server/RemoteServer/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,11 @@ + + + + + True|2024-10-28T10:24:22.2791029Z||;True|2024-10-28T17:30:28.6485638+08:00||;False|2024-10-28T17:29:49.7948159+08:00||; + + <_PublishTargetUrl>D:\git\FileSqlServerSync\Server\RemoteServer\bin\Release\net8.0\publish\ + + \ No newline at end of file diff --git a/Server/RemoteServer/RemoteServer.csproj.user b/Server/RemoteServer/RemoteServer.csproj.user index 94e6971..ac64b5f 100644 --- a/Server/RemoteServer/RemoteServer.csproj.user +++ b/Server/RemoteServer/RemoteServer.csproj.user @@ -5,5 +5,6 @@ http + D:\git\FileSqlServerSync\Server\RemoteServer\Properties\PublishProfiles\FolderProfile.pubxml \ No newline at end of file diff --git a/Server/RemoteServer/RemoteSyncServer.cs b/Server/RemoteServer/RemoteSyncServer.cs index 76b7a40..fa61859 100644 --- a/Server/RemoteServer/RemoteSyncServer.cs +++ b/Server/RemoteServer/RemoteSyncServer.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using System.Net.WebSockets; using Common; @@ -13,7 +14,78 @@ public class RemoteSyncServer public void SetStateHelpBase(StateHelpBase stateHelper) { - StateHelper = stateHelper; + try + { + StateHelper = stateHelper; + if (SyncConfig != null) + { + var LastExec = NotNullSyncConfig.ExecProcesses.Find(x => + { + return x.StepBeforeOrAfter == "A" + && x.Step == (stateHelper.Step - 1) + && x.ExecInLocalOrServer == "S"; + }); + ExecProcess(LastExec); + var CurrentExec = NotNullSyncConfig.ExecProcesses.Find(x => + { + return x.StepBeforeOrAfter == "B" + && x.Step == stateHelper.Step + && x.ExecInLocalOrServer == "S"; + }); + ExecProcess(CurrentExec); + } + } + catch (Exception ex) + { + Close(ex.Message); + } + } + + public void ExecProcess(ExecProcess? ep) + { + if (ep != null) + { + ProcessStartInfo startInfo = + new() + { + StandardOutputEncoding = System.Text.Encoding.UTF8, + Arguments = ep.Argumnets, + FileName = ep.FileName, // The command to execute (can be any command line tool) + // The arguments to pass to the command (e.g., list directory contents) + RedirectStandardOutput = true, // Redirect the standard output to a string + UseShellExecute = false, // Do not use the shell to execute the command + CreateNoWindow = true // Do not create a new window for the command + }; + using Process process = new() { StartInfo = startInfo }; + // Start the process + process.Start(); + + // Read the output from the process + string output = process.StandardOutput.ReadToEnd(); + + // Wait for the process to exit + process.WaitForExit(); + + if (process.ExitCode == 0) + { + Pipe.SendMsg( + StateHelper.CreateMsg( + $"{ep.Step}-{ep.StepBeforeOrAfter}-{ep.ExecInLocalOrServer}-{ep.FileName} {ep.Argumnets} 执行成功!" + ) + ) + .Wait(); + } + else + { + Pipe.SendMsg( + StateHelper.CreateMsg( + $"{ep.Step}-{ep.StepBeforeOrAfter}-{ep.ExecInLocalOrServer}-{ep.FileName} {ep.Argumnets} 失败 {output}!" + ) + ) + .Wait(); + throw new Exception("错误,信息参考上一条消息!"); + } + } } public StateHelpBase GetStateHelpBase() diff --git a/Server/RemoteServer/StateHelper.cs b/Server/RemoteServer/StateHelper.cs index 8129db1..0d249ee 100644 --- a/Server/RemoteServer/StateHelper.cs +++ b/Server/RemoteServer/StateHelper.cs @@ -13,7 +13,7 @@ public abstract class StateHelpBase( { protected readonly RemoteSyncServer Context = context; - protected readonly SyncProcessStep Step = step; + public readonly SyncProcessStep Step = step; public SyncMsg CreateErrMsg(string Body) { @@ -42,7 +42,7 @@ public abstract class StateHelpBase( var syncMsg = JsonSerializer.Deserialize(msg) ?? throw new NullReferenceException("msg is null"); - if (syncMsg.Step != Step) + if (syncMsg.Step != Step && syncMsg.Step != SyncProcessStep.Close) { throw new Exception("Sync step error!"); } @@ -134,7 +134,14 @@ public class UnPackAndReleaseHelper(RemoteSyncServer context) Context.Pipe.SendMsg(h.CreateMsg("将要发布数据库,可能时间会较长!")).Wait(); Task.Run(() => { - h.FinallyPublish(); + try + { + h.FinallyPublish(); + } + catch (Exception e) + { + Context.Close(e.Message); + } }); } @@ -154,6 +161,9 @@ public class FinallyPublishHelper(RemoteSyncServer context) + $" /TargetServerName:{Context.NotNullSyncConfig.DstDb.ServerName} /TargetDatabaseName:{Context.NotNullSyncConfig.DstDb.DatabaseName}" + $" /TargetUser:{Context.NotNullSyncConfig.DstDb.User} /TargetPassword:{Context.NotNullSyncConfig.DstDb.Password} /TargetTrustServerCertificate:True"; + //Context + // .Pipe.SendMsg(CreateMsg($"发布脚本为: {RemoteSyncServer.SqlPackageAbPath} {arguments}")) + // .Wait(); ProcessStartInfo startInfo = new() { @@ -201,8 +211,15 @@ public class FinallyPublishHelper(RemoteSyncServer context) } }); + Context.SetStateHelpBase(new NormalCloseHelper(Context)); Context.Pipe.SendMsg(CreateMsg("发布完成!")).Wait(); } protected override void HandleMsg(SyncMsg msg) { } } + +public class NormalCloseHelper(RemoteSyncServer context) + : StateHelpBase(context, SyncProcessStep.Close) +{ + protected override void HandleMsg(SyncMsg msg) { } +} diff --git a/Server/ServerTest/PipeSeed.cs b/Server/ServerTest/PipeSeed.cs index b3ff435..ce3aa1a 100644 --- a/Server/ServerTest/PipeSeed.cs +++ b/Server/ServerTest/PipeSeed.cs @@ -45,6 +45,36 @@ public class PipeSeed : IDisposable DirFileConfigs = new List { new DirFileConfig { DirPath = "/bin", Excludes = ["/roslyn", "/Views"] } + }, + + // C:/Windows/System32/inetsrv/appcmd.exe stop sites "publicserver" + // C:/Windows/System32/inetsrv/appcmd.exe start sites "publicserver" + ExecProcesses = new List + { + new ExecProcess + { + Argumnets = "ls", + FileName = "powershell", + StepBeforeOrAfter = "A", + ExecInLocalOrServer = "L", + Step = SyncProcessStep.DeployProject, + }, + new ExecProcess + { + Argumnets = "ls", + FileName = "powershell", + StepBeforeOrAfter = "B", + ExecInLocalOrServer = "S", + Step = SyncProcessStep.Publish, + }, + new ExecProcess + { + Argumnets = "ls", + FileName = "powershell", + StepBeforeOrAfter = "A", + ExecInLocalOrServer = "S", + Step = SyncProcessStep.Publish, + }, } }; } diff --git a/Server/ServerTest/PipeTest.cs b/Server/ServerTest/PipeTest.cs index 0768820..a5b2ec8 100644 --- a/Server/ServerTest/PipeTest.cs +++ b/Server/ServerTest/PipeTest.cs @@ -14,7 +14,12 @@ public class PipeTest [Fact] public async void TestCase() { - //msbuild ֻwindows + //if (System.IO.File.Exists("Pipe.txt")) + //{ + // System.IO.File.Delete("Pipe.txt"); + //} + //System.IO.File.Create("Pipe.txt"); + //msbuild ֻwindows if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var p1 = new TestPipe(false, "1"); @@ -27,9 +32,18 @@ public class PipeTest #pragma warning disable CS8602 // Dereference of a possibly null reference. if (msg.Body == "ɣ") { - _ = p1.Close("˳"); + Task.Run(() => + { + Task.Delay(1000).Wait(); + _ = p1.Close("˳"); + }); } #pragma warning restore CS8602 // Dereference of a possibly null reference. + System.IO.File.AppendAllText( + "Pipe.txt", + $"{msg.Step}-{msg.Type}:{msg.Body}\n" + ); + Console.WriteLine(b); return true; } diff --git a/Tool/JsScript/release.js b/Tool/JsScript/release.js index f4b4c17..768278f 100644 --- a/Tool/JsScript/release.js +++ b/Tool/JsScript/release.js @@ -7,21 +7,21 @@ const LocalHost = "127.0.0.1"; //这是个例子,请在`config`中写你的配置 const example_config = { //发布的名称,每个项目具有唯一的一个名称 - Name: "Test", - RemotePwd: "t123", + Name: "FYMF", + RemotePwd: "FYMF", //远程服务器地址,也就是发布的目的地,它是正式环境 - RemoteUrl: "127.0.0.1:6819", + RemoteUrl: "127.0.0.1:8007", //是否发布数据库 sqlserver IsDeployDb: false, //是否发布前重新构建项目 - IsDeployProject: false, + IsDeployProject: true, //项目地址 LocalProjectAbsolutePath: "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB", //源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录! LocalRootPath: "D:/FileSyncTest/src", //目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径 - RemoteRootPath: "D:/FileSyncTest/dst", + RemoteRootPath: "D:/FYMF", //源数据库配置 SqlServer,将会同步数据库的结构 SrcDb: { //Host @@ -45,7 +45,7 @@ const example_config = { ServerName: "127.0.0.1", DatabaseName: "HMES_H7_HNFYMF", User: "sa", - Password: "0", + Password: "Yuanmo520...", TrustServerCertificate: "True", }, //子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行, @@ -60,58 +60,58 @@ const example_config = { ], }; const config = { - //发布的名称,每个项目具有唯一的一个名称 - Name: "Test", - RemotePwd: "t123", - //远程服务器地址,也就是发布的目的地,它是正式环境 - RemoteUrl: "127.0.0.1:6819", - //是否发布数据库 sqlserver - IsDeployDb: true, - //是否发布前重新构建项目 - IsDeployProject: true, - //项目地址 - LocalProjectAbsolutePath: - "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB", - //源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录! - LocalRootPath: "D:/FileSyncTest/src", - //目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径 - RemoteRootPath: "D:/FileSyncTest/dst", - //源数据库配置 SqlServer,将会同步数据库的结构 - SrcDb: { - //Host - ServerName: "172.16.12.2", - //数据库名 - DatabaseName: "HMES_H7_HNFYMF", - User: "hmes-h7", - Password: "Hmes-h7666", - //是否信任服务器证书 - TrustServerCertificate: "True", - //同步的数据,这些数据将会同步 - SyncTablesData: [ - "dbo.sys_Button", - "dbo.sys_Menu", - "dbo.sys_Module", - "dbo.sys_Page", - ], - }, - //目标数据库配置 sqlserver - DstDb: { - ServerName: "127.0.0.1", - DatabaseName: "HMES_H7_HNFYMF", - User: "sa", - Password: "0", - TrustServerCertificate: "True", - }, - //子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行, - DirFileConfigs: [ - { - DirPath: "/bin", - //排除的文件或目录,它是相对路径,相对于!!!LocalRootPath和RemoteRootPath!!! - Excludes: ["/roslyn", "/Views"], - //只追踪文件或目录,它是相对路径,相对于!!!LocalRootPath和RemoteRootPath!!!,它的优先级最高,如果你指定了它的值,Excludes将会失效 - // CherryPicks:[] - }, - ], + //发布的名称,每个项目具有唯一的一个名称 + Name: "FYMF", + RemotePwd: "FYMF", + //远程服务器地址,也就是发布的目的地,它是正式环境 + RemoteUrl: "127.0.0.1:8007", + //是否发布数据库 sqlserver + IsDeployDb: true, + //是否发布前重新构建项目 + IsDeployProject: false, + //项目地址 + LocalProjectAbsolutePath: + "D:/git/HMES-H7-HNFY/HMES-H7-HNFYMF/HMES-H7-HNFYMF.WEB", + //源文件目录地址,是要发布的文件根目录,它是绝对路径,!执行发布时将发布到这个目录! + LocalRootPath: "D:/FileSyncTest/src", + //目标文件目录地址,也就是部署服务的机器上的项目文件根目录,它是绝对路径 + RemoteRootPath: "D:/FYMF", + //源数据库配置 SqlServer,将会同步数据库的结构 + SrcDb: { + //Host + ServerName: "172.16.12.2", + //数据库名 + DatabaseName: "HMES_H7_HNFYMF", + User: "hmes-h7", + Password: "Hmes-h7666", + //是否信任服务器证书 + TrustServerCertificate: "True", + //同步的数据,这些数据将会同步 + SyncTablesData: [ + "dbo.sys_Button", + "dbo.sys_Menu", + "dbo.sys_Module", + "dbo.sys_Page", + ], + }, + //目标数据库配置 sqlserver + DstDb: { + ServerName: "127.0.0.1", + DatabaseName: "HMES_H7_HNFYMF", + User: "sa", + Password: "Yuanmo520...", + TrustServerCertificate: "True", + }, + //子目录配置,每个子目录都有自己不同的发布策略,它是相对路径,即相对于LocalRootPath和RemoteRootPath(注意 '/',这将拼成一个完整的路径),文件数据依此进行, + DirFileConfigs: [ + { + DirPath: "/bin", + //排除的文件或目录,它是相对路径,相对于!!!LocalRootPath和RemoteRootPath!!! + Excludes: ["/roslyn", "/Views"], + //只追踪文件或目录,它是相对路径,相对于!!!LocalRootPath和RemoteRootPath!!!,它的优先级最高,如果你指定了它的值,Excludes将会失效 + // CherryPicks:[] + }, + ], }; //#endregion