diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e41bccbf..00fba943 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,14 +37,14 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - prerelease: ${{ contains(github.ref, '-') }} + prerelease: true draft: false files: | Netch.7z body: | [![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/netch_channel) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/netch_group) - [**第一次使用请务必先安装 .NET 5.0 运行库**](https://aka.ms/dotnet/5.0/windowsdesktop-runtime-win-x64.exe) + [**第一次使用请务必先安装 .NET 6.0 运行库,不支持 .NET 5.0**](https://aka.ms/dotnet/6.0/windowsdesktop-runtime-win-x64.exe) ## Changelogs * This is an automated deployment of GitHub Actions, the change log should be updated manually soon diff --git a/Netch.sln b/Netch.sln index 912961af..4929ff2f 100644 --- a/Netch.sln +++ b/Netch.sln @@ -12,7 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AdditionalFiles", "Addition .editorconfig = .editorconfig .gitignore = .gitignore common.props = common.props - global.json = global.json LICENSE = LICENSE README.md = README.md EndProjectSection diff --git a/Netch/App.manifest b/Netch/App.manifest index 437cbe53..348bfce2 100644 --- a/Netch/App.manifest +++ b/Netch/App.manifest @@ -10,7 +10,6 @@ - True/PM diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 69c3eb55..566c2143 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -107,7 +107,7 @@ namespace Netch.Forms if (Global.Settings.StartWhenOpened) ControlButton.PerformClick(); - Program.SingleInstance.ListenForArgumentsFromSuccessiveInstances(); + Program.SingleInstance.StartListenServer(); } private void RecordSize() diff --git a/Netch/Netch.csproj b/Netch/Netch.csproj index 192cc009..a6c233c1 100644 --- a/Netch/Netch.csproj +++ b/Netch/Netch.csproj @@ -30,10 +30,10 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -43,17 +43,16 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - + + - - + + @@ -78,13 +77,6 @@ <_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\build\native\x86\**" /> - - <_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\lib\netstandard1.6\Dia2Lib.dll" /> - <_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\lib\netstandard1.6\OSExtensions.dll" /> - <_FilesToBundle Remove="$(PkgMicrosoft_Diagnostics_Tracing_TraceEvent)\lib\netstandard1.6\TraceReloggerLib.dll" /> diff --git a/Netch/Program.cs b/Netch/Program.cs index 19cdf8db..244c5424 100644 --- a/Netch/Program.cs +++ b/Netch/Program.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; @@ -27,7 +26,7 @@ namespace Netch { public static class Program { - public static readonly SingleInstanceService SingleInstance = new($"Global\\{nameof(Netch)}"); + public static readonly ISingleInstanceService SingleInstance = new SingleInstanceService($"Global\\{nameof(Netch)}"); internal static HWND ConsoleHwnd { get; private set; } @@ -70,14 +69,14 @@ namespace Netch Configuration.LoadAsync().Wait(); // check if the program is already running - if (!SingleInstance.IsFirstInstance) + if (!SingleInstance.TryStartSingleInstance()) { - SingleInstance.PassArgumentsToFirstInstance(args.Append(Constants.Parameter.Show)); + SingleInstance.SendMessageToFirstInstanceAsync(Constants.Parameter.Show).GetAwaiter().GetResult(); Environment.Exit(0); return; } - SingleInstance.ArgumentsReceived.Subscribe(SingleInstance_ArgumentsReceived); + SingleInstance.Received.Subscribe(SingleInstance_ArgumentsReceived); // clean up old logs if (Directory.Exists("logging")) @@ -108,7 +107,7 @@ namespace Netch Application.ThreadException += Application_OnException; Application.ApplicationExit += Application_OnExit; - Application.SetHighDpiMode(HighDpiMode.SystemAware); + Application.SetHighDpiMode(HighDpiMode.DpiUnawareGdiScaled); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(Global.MainForm); @@ -207,12 +206,15 @@ namespace Netch Log.CloseAndFlush(); } - private static void SingleInstance_ArgumentsReceived(IEnumerable args) + private static void SingleInstance_ArgumentsReceived((string, Action) receive) { - if (args.Contains(Constants.Parameter.Show)) + var (arg, endFunc) = receive; + if (arg == Constants.Parameter.Show) { Utils.Utils.ActivateVisibleWindows(); } + + endFunc(string.Empty); } } } \ No newline at end of file diff --git a/README.md b/README.md index 34951e03..bb46939d 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Some features may not be implemented in version 1 ### Others - UDP NAT FullCone (May limited by your server) -- .NET 5.0 x64 +- .NET 6.0 x64 ## Sponsor JetBrains diff --git a/build.ps1 b/build.ps1 index c486f47e..14e8c86c 100644 --- a/build.ps1 +++ b/build.ps1 @@ -32,6 +32,7 @@ dotnet publish ` -r 'win-x64' ` -p:Platform='x64' ` -p:SelfContained=$SelfContained ` + $('--self-contained', '--no-self-contained')[$SelfContained] ` -p:PublishTrimmed=$False ` -p:PublishReadyToRun=$PublishReadyToRun ` -p:PublishSingleFile=$PublishSingleFile ` diff --git a/common.props b/common.props index 716d1013..2d142edd 100644 --- a/common.props +++ b/common.props @@ -1,6 +1,6 @@ - net5.0-windows + net6.0-windows win-x64 x64 latest diff --git a/global.json b/global.json deleted file mode 100644 index a8ab760d..00000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "sdk": { - "allowPrerelease": false - } -} \ No newline at end of file