File tree Expand file tree Collapse file tree 2 files changed +25
-19
lines changed Expand file tree Collapse file tree 2 files changed +25
-19
lines changed Original file line number Diff line number Diff line change
1
+ using System . Reflection ;
2
+
3
+ namespace GitCredentialManager ;
4
+
5
+ public static class AssemblyUtils
6
+ {
7
+ public static bool TryGetAssemblyVersion ( out string version )
8
+ {
9
+ try
10
+ {
11
+ var assembly = Assembly . GetEntryAssembly ( ) ?? Assembly . GetExecutingAssembly ( ) ;
12
+ var assemblyVersionAttribute = assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ;
13
+ version = assemblyVersionAttribute is null
14
+ ? assembly . GetName ( ) . Version . ToString ( )
15
+ : assemblyVersionAttribute . InformationalVersion ;
16
+ return true ;
17
+ }
18
+ catch
19
+ {
20
+ version = null ;
21
+ return false ;
22
+ }
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ private async Task<int> ExecuteAsync(string output)
86
86
fullLog . WriteLine ( $ "AppPath: { _context . ApplicationPath } ") ;
87
87
fullLog . WriteLine ( $ "InstallDir: { _context . InstallationDirectory } ") ;
88
88
fullLog . WriteLine (
89
- TryGetAssemblyVersion ( out string version )
89
+ AssemblyUtils . TryGetAssemblyVersion ( out string version )
90
90
? $ "Version: { version } "
91
91
: "Version: [!] Failed to get version information [!]"
92
92
) ;
@@ -198,24 +198,6 @@ private async Task<int> ExecuteAsync(string output)
198
198
return numFailed ;
199
199
}
200
200
201
- private bool TryGetAssemblyVersion ( out string version )
202
- {
203
- try
204
- {
205
- var assembly = Assembly . GetEntryAssembly ( ) ?? Assembly . GetExecutingAssembly ( ) ;
206
- var assemblyVersionAttribute = assembly . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ;
207
- version = assemblyVersionAttribute is null
208
- ? assembly . GetName ( ) . Version . ToString ( )
209
- : assemblyVersionAttribute . InformationalVersion ;
210
- return true ;
211
- }
212
- catch
213
- {
214
- version = null ;
215
- return false ;
216
- }
217
- }
218
-
219
201
private static class ConsoleEx
220
202
{
221
203
public static void WriteLineIndent ( string str )
You can’t perform that action at this time.
0 commit comments