Skip to content

Commit fc0d03c

Browse files
authored
Merge pull request #31 from YJammak/develop
修复发布后置顶和开机启动失效的问题
2 parents 68e175a + 1e52130 commit fc0d03c

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2-
<ReactiveUI />
3-
</Weavers>
2+
<ReactiveUI />
3+
<Anotar.NLog />
4+
</Weavers>

src/WeatherCalendar/FodyWeavers.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<xs:complexType>
66
<xs:all>
77
<xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" />
8+
<xs:element name="Anotar.NLog" minOccurs="0" maxOccurs="1" type="xs:anyType" />
89
</xs:all>
910
<xs:attribute name="VerifyAssembly" type="xs:boolean">
1011
<xs:annotation>

src/WeatherCalendar/Utils/AppHelper.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Win32;
1+
using Anotar.NLog;
2+
using Microsoft.Win32;
23
using System;
34
using System.Diagnostics;
45
using System.Linq;
@@ -11,7 +12,7 @@ public static class AppHelper
1112
{
1213
private static string AppName => "WeatherCalendar";
1314

14-
private static string AppFullName => Application.Current.GetType().Assembly.Location.Replace(".dll", ".exe");
15+
private static string AppFullName => Process.GetCurrentProcess()!.MainModule!.FileName;
1516

1617
public static bool IsAutoStart()
1718
{
@@ -43,9 +44,9 @@ public static void Restart()
4344
Process.Start(process);
4445
Application.Current.Shutdown();
4546
}
46-
catch
47+
catch (Exception ex)
4748
{
48-
//
49+
LogTo.ErrorException("重启失败", ex);
4950
}
5051
}
5152

@@ -66,9 +67,9 @@ public static void RequiredAdministrator()
6667
Process.Start(process);
6768
Application.Current.Shutdown();
6869
}
69-
catch
70+
catch (Exception ex)
7071
{
71-
//
72+
LogTo.ErrorException("请求管理员权限失败", ex);
7273
}
7374
}
7475

@@ -139,8 +140,9 @@ private static bool SetAutoStart(bool isAutoStart, string appName, string appFul
139140
}
140141
}
141142
}
142-
catch
143+
catch (Exception ex)
143144
{
145+
LogTo.ErrorException("修改开启自启注册表失败", ex);
144146
return false;
145147
}
146148

src/WeatherCalendar/WeatherCalendar.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24+
<PackageReference Include="Anotar.NLog.Fody" Version="6.0.0">
25+
<PrivateAssets>all</PrivateAssets>
26+
</PackageReference>
2427
<PackageReference Include="DynamicData" Version="7.12.1" />
2528
<PackageReference Include="Enums.NET" Version="4.0.0" />
29+
<PackageReference Include="Fody" Version="6.6.4">
30+
<PrivateAssets>all</PrivateAssets>
31+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
32+
</PackageReference>
2633
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.73" />
2734
<PackageReference Include="MaterialDesignThemes" Version="4.6.1" />
2835
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
36+
<PackageReference Include="NLog" Version="5.0.4" />
2937
<PackageReference Include="NPinyin.Core" Version="3.0.0" />
3038
<PackageReference Include="ReactiveUI.Events.WPF" Version="15.1.1" />
3139
<PackageReference Include="ReactiveUI.Fody" Version="18.3.1" />

0 commit comments

Comments
 (0)