mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feature<Project>: supports build with .NET 6
This commit is contained in:
parent
898599afc9
commit
3628729a93
5 changed files with 74 additions and 7 deletions
14
build.bat
14
build.bat
|
@ -25,4 +25,18 @@ dotnet publish SourceGit.csproj --nologo -c Release -r win-x64 -f net5.0-windows
|
|||
cd ..\publish
|
||||
ren SourceGit.exe SourceGit.net5.0.x64.exe
|
||||
|
||||
cd ..\src
|
||||
rmdir /s /q bin
|
||||
rmdir /s /q obj
|
||||
dotnet publish SourceGit.csproj --nologo -c Release -r win-x86 -f net6.0-windows -p:PublishSingleFile=true --no-self-contained -o ..\publish
|
||||
cd ..\publish
|
||||
ren SourceGit.exe SourceGit.net6.0.x86.exe
|
||||
|
||||
cd ..\src
|
||||
rmdir /s /q bin
|
||||
rmdir /s /q obj
|
||||
dotnet publish SourceGit.csproj --nologo -c Release -r win-x64 -f net6.0-windows -p:PublishSingleFile=true --no-self-contained -o ..\publish
|
||||
cd ..\publish
|
||||
ren SourceGit.exe SourceGit.net6.0.x64.exe
|
||||
|
||||
cd ../
|
|
@ -1,10 +1,15 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Net.Http;
|
||||
#else
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
#endif
|
||||
|
||||
namespace SourceGit.Models {
|
||||
/// <summary>
|
||||
/// 崩溃日志上报
|
||||
|
@ -40,6 +45,13 @@ namespace SourceGit.Models {
|
|||
e.Source,
|
||||
e.StackTrace);
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
var req = new HttpClient();
|
||||
req.DefaultRequestHeaders.Add("Content-Type", "application/json");
|
||||
req.DefaultRequestHeaders.Add("charset", "UTF-8");
|
||||
req.Timeout = TimeSpan.FromSeconds(1);
|
||||
req.PostAsync("https://gitee.com/api/v5/repos/sourcegit/issues", new StringContent(JsonSerializer.Serialize(issue))).Wait();
|
||||
#else
|
||||
var req = WebRequest.CreateHttp("https://gitee.com/api/v5/repos/sourcegit/issues");
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/json";
|
||||
|
@ -53,6 +65,7 @@ namespace SourceGit.Models {
|
|||
}
|
||||
|
||||
req.GetResponse();
|
||||
#endif
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Net.Http;
|
||||
#else
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
#endif
|
||||
|
||||
namespace SourceGit.Models {
|
||||
|
||||
/// <summary>
|
||||
|
@ -43,10 +48,18 @@ namespace SourceGit.Models {
|
|||
var lastDayOfYear = Preference.Instance.General.LastCheckDay;
|
||||
if (lastDayOfYear != curDayOfYear) {
|
||||
Preference.Instance.General.LastCheckDay = curDayOfYear;
|
||||
Task.Run(() => {
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
#if NET6_0_OR_GREATER
|
||||
var req = new HttpClient();
|
||||
var rsp = await req.GetAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
|
||||
rsp.EnsureSuccessStatusCode();
|
||||
|
||||
var raw = await rsp.Content.ReadAsStringAsync();
|
||||
#else
|
||||
var web = new WebClient() { Encoding = Encoding.UTF8 };
|
||||
var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
|
||||
var raw = await web.DownloadStringTaskAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
|
||||
#endif
|
||||
var ver = JsonSerializer.Deserialize<Version>(raw);
|
||||
var cur = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0-windows;net48</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows;net5.0-windows;net48</TargetFrameworks>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>App.ico</ApplicationIcon>
|
||||
|
|
|
@ -11,6 +11,10 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.Net.Http;
|
||||
#endif
|
||||
|
||||
namespace SourceGit.Views.Controls {
|
||||
|
||||
/// <summary>
|
||||
|
@ -192,6 +196,28 @@ namespace SourceGit.Views.Controls {
|
|||
if (!requesting.ContainsKey(email)) return;
|
||||
|
||||
try {
|
||||
#if NET6_0_OR_GREATER
|
||||
var req = new HttpClient().GetAsync(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
||||
req.Wait();
|
||||
|
||||
var rsp = req.Result;
|
||||
if (rsp != null && rsp.StatusCode == HttpStatusCode.OK) {
|
||||
var writer = File.OpenWrite(filePath);
|
||||
rsp.Content.CopyToAsync(writer).Wait();
|
||||
writer.Close();
|
||||
|
||||
a.Dispatcher.Invoke(() => {
|
||||
var img = new BitmapImage(new Uri(filePath));
|
||||
loaded.Add(email, img);
|
||||
|
||||
if (requesting.ContainsKey(email)) {
|
||||
foreach (var one in requesting[email]) one.Source = img;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||
}
|
||||
#else
|
||||
HttpWebRequest req = WebRequest.CreateHttp(Models.Preference.Instance.General.AvatarServer + md5 + "?d=404");
|
||||
req.Timeout = 2000;
|
||||
req.Method = "GET";
|
||||
|
@ -214,6 +240,7 @@ namespace SourceGit.Views.Controls {
|
|||
} else {
|
||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||
}
|
||||
#endif
|
||||
} catch {
|
||||
if (!loaded.ContainsKey(email)) loaded.Add(email, null);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue