Skip to content

Commit e2ef463

Browse files
committed
Refactoring
1 parent 1ce0836 commit e2ef463

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

UnturnedRedistUpdateTool/Program.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,28 @@ public static async Task<int> Main(string[] args)
7474
var statusFilePath = Path.Combine(unturnedPath, statusFileName);
7575
if (File.Exists(statusFilePath) == false)
7676
{
77-
throw new FileNotFoundException("Required file is not found", statusFilePath);
77+
throw new FileNotFoundException("Status file is not found", statusFilePath);
7878
}
7979
var (version, buildId) = await GetInfo(unturnedPath, steamappsDirectory, AppId);
8080

8181
Console.WriteLine($"Found Unturned v{version} ({buildId})");
8282

8383
var doc = XDocument.Load(nuspecFilePath, LoadOptions.PreserveWhitespace);
84-
XNamespace ns = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd";
84+
var ns = "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd";
8585
var versionElement = doc.Root.Element(ns + "metadata").Element(ns + "version");
86-
if (versionElement != null)
86+
if (versionElement == null)
8787
{
88-
Console.WriteLine($"nuspec version: {versionElement.Value}");
89-
if (version == versionElement.Value)
90-
{
91-
Console.WriteLine("Unturned Version is the same as in nuspec, it means new version is not detected, skipping...");
92-
return 1;
93-
}
94-
versionElement.Value = version;
88+
Console.WriteLine("Version element not found in nuspec file!");
89+
return 1;
9590
}
96-
else
91+
92+
Console.WriteLine($"nuspec version: {versionElement.Value}");
93+
if (version == versionElement.Value)
9794
{
98-
Console.WriteLine("Version element not found in nuspec file!");
95+
Console.WriteLine("Unturned Version is the same as in nuspec, it means new version is not detected, skipping...");
9996
return 1;
10097
}
98+
versionElement.Value = version;
10199

102100
doc.Save(nuspecFilePath);
103101

@@ -157,10 +155,9 @@ Dictionary<string, string> UpdateRedist(string unturnedManagedDirectory)
157155
fileInfo.CopyTo(redistFilePath, true);
158156
updatedFiles.Add(managedFilePath, redistFilePath);
159157
}
160-
catch (Exception)
158+
catch (Exception ex)
161159
{
162-
Console.WriteLine($"An error occured while updating file: \"{fileInfo.FullName}\".");
163-
throw;
160+
throw new Exception($"An error occured while updating file: \"{fileInfo.FullName}\".", ex);
164161
}
165162
}
166163

0 commit comments

Comments
 (0)