upgrade<project>: upgrade to .NET 5

This commit is contained in:
leo 2021-03-02 10:57:19 +08:00
parent 672783390b
commit c68b333c1d
5 changed files with 20 additions and 18 deletions

5
build.bat Normal file
View file

@ -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 ..

View file

@ -1,10 +1,10 @@
using Microsoft.Win32; using Microsoft.Win32;
using Newtonsoft.Json;
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -79,7 +79,7 @@ namespace SourceGit {
var dir = Path.GetDirectoryName(settingFile); var dir = Path.GetDirectoryName(settingFile);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); 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); File.WriteAllText(settingFile, data);
} }
@ -100,7 +100,7 @@ namespace SourceGit {
if (!File.Exists(settingFile)) { if (!File.Exists(settingFile)) {
Setting = new Preference(); Setting = new Preference();
} else { } else {
Setting = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(settingFile)); Setting = JsonSerializer.Deserialize<Preference>(File.ReadAllText(settingFile));
} }
// Try auto configure git via registry. // Try auto configure git via registry.
@ -196,7 +196,7 @@ namespace SourceGit {
try { try {
var web = new WebClient() { Encoding = Encoding.UTF8 }; var web = new WebClient() { Encoding = Encoding.UTF8 };
var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/SourceGit/releases/latest"); var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/SourceGit/releases/latest");
var ver = JsonConvert.DeserializeObject<Git.Version>(raw); var ver = JsonSerializer.Deserialize<Git.Version>(raw);
var cur = Assembly.GetExecutingAssembly().GetName().Version; var cur = Assembly.GetExecutingAssembly().GetName().Version;
var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*"); var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*");

View file

@ -1,9 +1,9 @@
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Threading; using System.Windows.Threading;

View file

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System; using System;
using System.Text.Json.Serialization;
namespace SourceGit.Git { namespace SourceGit.Git {
@ -7,19 +7,19 @@ namespace SourceGit.Git {
/// Version information. /// Version information.
/// </summary> /// </summary>
public class Version { public class Version {
[JsonProperty(PropertyName = "id")] [JsonPropertyName("id")]
public ulong Id { get; set; } public ulong Id { get; set; }
[JsonProperty(PropertyName = "tag_name")] [JsonPropertyName("tag_name")]
public string TagName { get; set; } public string TagName { get; set; }
[JsonProperty(PropertyName = "target_commitish")] [JsonPropertyName("target_commitish")]
public string CommitSHA { get; set; } public string CommitSHA { get; set; }
[JsonProperty(PropertyName = "prerelease")] [JsonPropertyName("prerelease")]
public bool PreRelease { get; set; } public bool PreRelease { get; set; }
[JsonProperty(PropertyName = "name")] [JsonPropertyName("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty(PropertyName = "body")] [JsonPropertyName("body")]
public string Body { get; set; } public string Body { get; set; }
[JsonProperty(PropertyName = "created_at")] [JsonPropertyName("created_at")]
public DateTime CreatedAt { get; set; } public DateTime CreatedAt { get; set; }
} }
} }

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net48</TargetFramework> <TargetFramework>net5.0-windows</TargetFramework>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<ApplicationIcon>App.ico</ApplicationIcon> <ApplicationIcon>App.ico</ApplicationIcon>
@ -18,7 +18,4 @@
<DebugType>none</DebugType> <DebugType>none</DebugType>
<SatelliteResourceLanguages>none</SatelliteResourceLanguages> <SatelliteResourceLanguages>none</SatelliteResourceLanguages>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
</Project> </Project>