Skip to content

Commit 31c3a6b

Browse files
CopilotJusterZhu
andcommitted
Fix nullable warnings and improve exe file detection
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
1 parent b5c7d3f commit 31c3a6b

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/Common/CsprojReader.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,22 @@ private static string FindExeFile(string directory, string baseName)
144144

145145
try
146146
{
147+
// First try to find .exe file (Windows)
147148
var exeFiles = Directory.GetFiles(directory, $"{baseName}.exe", SearchOption.AllDirectories);
148-
return exeFiles.FirstOrDefault() ?? string.Empty;
149+
if (exeFiles.Any())
150+
return exeFiles.First();
151+
152+
// Then try to find executable without extension (Linux/Mac)
153+
var allFiles = Directory.GetFiles(directory, baseName, SearchOption.AllDirectories);
154+
foreach (var file in allFiles)
155+
{
156+
var fileInfo = new FileInfo(file);
157+
// Check if file is executable (on Unix systems) or if it's an exact match
158+
if (fileInfo.Name == baseName)
159+
return file;
160+
}
161+
162+
return string.Empty;
149163
}
150164
catch (Exception ex)
151165
{

src/Models/ConfigInfo.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ namespace GeneralUpdate.Tool.Avalonia.Models;
88
public class ConfigInfo
99
{
1010
[JsonProperty("reportUrl")]
11-
public string ReportUrl { get; set; }
11+
public string ReportUrl { get; set; } = string.Empty;
1212

1313
[JsonProperty("updateUrl")]
14-
public string UpdateUrl { get; set; }
14+
public string UpdateUrl { get; set; } = string.Empty;
1515

1616
[JsonProperty("appName")]
17-
public string AppName { get; set; }
17+
public string AppName { get; set; } = string.Empty;
1818

1919
[JsonProperty("mainAppName")]
20-
public string MainAppName { get; set; }
20+
public string MainAppName { get; set; } = string.Empty;
2121

2222
[JsonProperty("clientVersion")]
23-
public string ClientVersion { get; set; }
23+
public string ClientVersion { get; set; } = string.Empty;
2424

2525
[JsonProperty("packetName")]
26-
public string PacketName { get; set; }
26+
public string PacketName { get; set; } = string.Empty;
2727

2828
[JsonProperty("format")]
29-
public string Format { get; set; }
29+
public string Format { get; set; } = string.Empty;
3030

3131
[JsonProperty("encoding")]
32-
public string Encoding { get; set; }
32+
public string Encoding { get; set; } = string.Empty;
3333
}

0 commit comments

Comments
 (0)