upgrade<Project>: retargets to .net framework 4.8

This commit is contained in:
leo 2022-10-26 10:32:42 +08:00
parent 476c23f9d2
commit 5d71e54547
10 changed files with 35 additions and 31 deletions

View file

@ -29,11 +29,6 @@ Opensouce Git GUI client for Windows.
Pre-build Binaries[Releases](https://github.com/sourcegit-scm/sourcegit/releases)
| File | .NET runtime | Description |
| ------------------------ | ------------------ | --------------------------------- |
| SourceGit.exe | .NET 6 x64 | Need to be installed by user. |
| SourceGit.bundle.exe | Self-contained | - |
> NOTE: You need install Git first.
## Screen Shots

View file

@ -3,10 +3,15 @@
rmdir /s /q publish
cd src
dotnet publish SourceGit.csproj --nologo -c Release -r win-x64 -f net6.0-windows -p:PublishSingleFile=true --no-self-contained -o ..\publish
dotnet publish SourceGit.csproj --nologo -c Release -r win-x64 -f net6.0-windows -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:PublishReadyToRun=true --self-contained -o ..\publish\tmp
move ..\publish\tmp\SourceGit.exe ..\publish\SourceGit.bundle.exe
rmdir /s /q ..\publish\tmp
del /f /s /q ..\publish\SourceGit.pdb
rmdir /s /q bin
rmdir /s /q obj
dotnet publish SourceGit.csproj --nologo -c Release -r win-x86 -f net48 -o ..\publish\net48
ilrepack /ndebug /wildcards /out:..\publish\SourceGit.exe ..\publish\net48\SourceGit.exe ..\publish\net48\*.dll
cd ..\publish
rmdir /s /q net48
cd ..

View file

@ -85,7 +85,7 @@ namespace SourceGit.Commands {
isCancelled = true;
proc.CancelErrorRead();
proc.CancelOutputRead();
if (!proc.HasExited) proc.Kill(true);
if (!proc.HasExited) proc.Kill();
return;
}
@ -97,7 +97,7 @@ namespace SourceGit.Commands {
isCancelled = true;
proc.CancelErrorRead();
proc.CancelOutputRead();
if (!proc.HasExited) proc.Kill(true);
if (!proc.HasExited) proc.Kill();
return;
}

View file

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-windows</TargetFrameworks>
<TargetFrameworks>net48</TargetFrameworks>
<OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF>
<ApplicationIcon>App.ico</ApplicationIcon>
@ -17,4 +17,7 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Json" Version="6.0.6" />
</ItemGroup>
</Project>

View file

@ -45,13 +45,13 @@ namespace SourceGit.Views {
var extras = string.IsNullOrEmpty(ExtraArgs) ? "" : ExtraArgs;
if (!string.IsNullOrEmpty(RemoteName)) extras += $" --origin {RemoteName}";
var succ = new Commands.Clone(Folder, Uri, LocalName, sshKey, extras, msg => {
var cloneRs = new Commands.Clone(Folder, Uri, LocalName, sshKey, extras, msg => {
Dispatcher.Invoke(() => txtProgress.Text = msg);
}, err => {
Dispatcher.Invoke(() => txtError.Text = err);
}).Exec();
if (!succ) return false;
if (!cloneRs) return false;
var path = Folder;
if (!string.IsNullOrEmpty(LocalName)) {

View file

@ -10,7 +10,6 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Net.Http;
namespace SourceGit.Views.Controls {
@ -193,14 +192,16 @@ namespace SourceGit.Views.Controls {
if (!requesting.ContainsKey(email)) return;
try {
var req = new HttpClient().GetAsync($"https://www.gravatar.com/avatar/{md5}?d=404");
req.Wait();
var req = WebRequest.CreateHttp($"https://www.gravatar.com/avatar/{md5}?d=404");
req.Timeout = 2000;
req.Method = "GET";
var rsp = req.Result;
var rsp = req.GetResponse() as HttpWebResponse;
if (rsp != null && rsp.StatusCode == HttpStatusCode.OK) {
var writer = File.OpenWrite(filePath);
rsp.Content.CopyToAsync(writer).Wait();
writer.Close();
using (var reader = rsp.GetResponseStream())
using (var writer = File.OpenWrite(filePath)) {
reader.CopyTo(writer);
}
a.Dispatcher.Invoke(() => {
var img = new BitmapImage(new Uri(filePath));

View file

@ -36,7 +36,7 @@ namespace SourceGit.Views {
GPGExec = cmd.Get("gpg.program");
if (string.IsNullOrEmpty(GPGExec)) {
string gitInstallFolder = Path.GetDirectoryName(Models.Preference.Instance.Git.Path);
string defaultGPG = Path.GetFullPath(Path.Join(gitInstallFolder, "..", "usr", "bin", "gpg.exe"));
string defaultGPG = Path.GetFullPath(gitInstallFolder + "/../usr/bin/gpg.exe");
if (File.Exists(defaultGPG)) GPGExec = defaultGPG;
}
GPGSigningEnabled = cmd.Get("commit.gpgsign") == "true";

View file

@ -74,11 +74,11 @@ namespace SourceGit.Views.Widgets {
} else {
searching = true;
foreach (var c in cachedCommits) {
if (c.SHA.Contains(filter, StringComparison.Ordinal)
|| c.Subject.Contains(filter, StringComparison.Ordinal)
|| c.Message.Contains(filter, StringComparison.Ordinal)
|| c.Author.Name.Contains(filter, StringComparison.Ordinal)
|| c.Committer.Name.Contains(filter, StringComparison.Ordinal)) {
if (c.SHA.IndexOf(filter, StringComparison.Ordinal) >= 0
|| c.Subject.IndexOf(filter, StringComparison.Ordinal) >= 0
|| c.Message.IndexOf(filter, StringComparison.Ordinal) >= 0
|| c.Author.Name.IndexOf(filter, StringComparison.Ordinal) >= 0
|| c.Committer.Name.IndexOf(filter, StringComparison.Ordinal) >= 0) {
visible.Add(c);
}
}

View file

@ -171,8 +171,8 @@ namespace SourceGit.Views.Widgets {
visibles.AddRange(Models.Preference.Instance.Repositories);
} else {
foreach (var repo in Models.Preference.Instance.Repositories) {
if (repo.Name.ToLower().Contains(curFilter, StringComparison.Ordinal) ||
repo.Path.ToLower().Contains(curFilter, StringComparison.Ordinal)) {
if (repo.Name.ToLower().IndexOf(curFilter, StringComparison.Ordinal) >= 0 ||
repo.Path.ToLower().IndexOf(curFilter, StringComparison.Ordinal) >= 0) {
visibles.Add(repo);
}
}

View file

@ -215,7 +215,7 @@ namespace SourceGit.Views.Widgets {
if (!added) Changes.Add(c);
int sepIdx = c.Path.IndexOf('/', StringComparison.Ordinal);
int sepIdx = c.Path.IndexOf("/", StringComparison.Ordinal);
if (sepIdx < 0) {
GetOrAddTreeNode(Nodes, c.Path, c, false);
} else {