diff --git a/build.bat b/build.bat new file mode 100644 index 00000000..1eb1ea34 --- /dev/null +++ b/build.bat @@ -0,0 +1,5 @@ +cd src +rmdir /s /q bin +rmdir /s /q obj +dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true --self-contained false +cd .. \ No newline at end of file diff --git a/src/App.xaml.cs b/src/App.xaml.cs index 57823bf4..76c2c926 100644 --- a/src/App.xaml.cs +++ b/src/App.xaml.cs @@ -1,10 +1,10 @@ using Microsoft.Win32; -using Newtonsoft.Json; using System; using System.IO; using System.Net; using System.Reflection; using System.Text; +using System.Text.Json; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; @@ -79,7 +79,7 @@ namespace SourceGit { var dir = Path.GetDirectoryName(settingFile); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); - var data = JsonConvert.SerializeObject(Setting, Formatting.Indented); + var data = JsonSerializer.Serialize(Setting, new JsonSerializerOptions() { WriteIndented = true }); File.WriteAllText(settingFile, data); } @@ -100,7 +100,7 @@ namespace SourceGit { if (!File.Exists(settingFile)) { Setting = new Preference(); } else { - Setting = JsonConvert.DeserializeObject(File.ReadAllText(settingFile)); + Setting = JsonSerializer.Deserialize(File.ReadAllText(settingFile)); } // Try auto configure git via registry. @@ -196,7 +196,7 @@ namespace SourceGit { try { var web = new WebClient() { Encoding = Encoding.UTF8 }; var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/SourceGit/releases/latest"); - var ver = JsonConvert.DeserializeObject(raw); + var ver = JsonSerializer.Deserialize(raw); var cur = Assembly.GetExecutingAssembly().GetName().Version; var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*"); diff --git a/src/Git/Repository.cs b/src/Git/Repository.cs index 3280185f..9f1bd463 100644 --- a/src/Git/Repository.cs +++ b/src/Git/Repository.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; +using System.Text.Json.Serialization; using System.Text.RegularExpressions; using System.Windows.Threading; diff --git a/src/Git/Version.cs b/src/Git/Version.cs index d3c670a8..02020610 100644 --- a/src/Git/Version.cs +++ b/src/Git/Version.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; using System; +using System.Text.Json.Serialization; namespace SourceGit.Git { @@ -7,19 +7,19 @@ namespace SourceGit.Git { /// Version information. /// public class Version { - [JsonProperty(PropertyName = "id")] + [JsonPropertyName("id")] public ulong Id { get; set; } - [JsonProperty(PropertyName = "tag_name")] + [JsonPropertyName("tag_name")] public string TagName { get; set; } - [JsonProperty(PropertyName = "target_commitish")] + [JsonPropertyName("target_commitish")] public string CommitSHA { get; set; } - [JsonProperty(PropertyName = "prerelease")] + [JsonPropertyName("prerelease")] public bool PreRelease { get; set; } - [JsonProperty(PropertyName = "name")] + [JsonPropertyName("name")] public string Name { get; set; } - [JsonProperty(PropertyName = "body")] + [JsonPropertyName("body")] public string Body { get; set; } - [JsonProperty(PropertyName = "created_at")] + [JsonPropertyName("created_at")] public DateTime CreatedAt { get; set; } } } diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 0f6dba97..ae2b439a 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -1,6 +1,6 @@ - + - net48 + net5.0-windows WinExe true App.ico @@ -18,7 +18,4 @@ none none - - - \ No newline at end of file