Skip to content

Commit

Permalink
don't modify csproj files if they don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Axwabo committed Feb 24, 2024
1 parent c44a804 commit 16a1e21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Editor/Updater/FileModification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static void PatchFiles(ProgressUpdater update, ChangedFile[] files, strin
return;
}

var projectFile = File.ReadAllLines(Constants.ProjectFileName).ToList();
var editorProjectFile = File.ReadAllLines(Constants.EditorProjectFileName).ToList();
var projectFile = File.Exists(Constants.ProjectFileName) ? File.ReadAllLines(Constants.ProjectFileName).ToList() : new List<string>();
var editorProjectFile = File.Exists(Constants.EditorProjectFileName) ? File.ReadAllLines(Constants.EditorProjectFileName).ToList() : new List<string>();
var count = files.Length;
var fc = (float) count;
for (var i = 0; i < count; i++)
Expand All @@ -61,8 +61,10 @@ public static void PatchFiles(ProgressUpdater update, ChangedFile[] files, strin
update(name, (i + 1) / fc);
}

File.WriteAllLines(Constants.ProjectFileName, projectFile);
File.WriteAllLines(Constants.EditorProjectFileName, editorProjectFile);
if (projectFile.Count != 0)
File.WriteAllLines(Constants.ProjectFileName, projectFile);
if (editorProjectFile.Count != 0)
File.WriteAllLines(Constants.EditorProjectFileName, editorProjectFile);
}

private static void ProcessPatch(ChangedFile file, ZipArchiveEntry entry, bool wasRemoved, string assets, List<string> projectFile, List<string> editorProjectFile)
Expand Down Expand Up @@ -93,7 +95,7 @@ private static void ProcessPatch(ChangedFile file, ZipArchiveEntry entry, bool w

private static void ModifyCsproj(string path, bool wasRemoved, string assets, List<string> list)
{
if (!path.EndsWith(".cs"))
if (!path.EndsWith(".cs") || list.Count == 0)
return;
var pathFromRoot = Path.GetRelativePath(Directory.GetParent(assets)!.FullName, path).Replace('\\', '/');
var existingIndex = list.FindIndex(s =>
Expand Down
2 changes: 1 addition & 1 deletion Scripts/slocExporter/API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class API

public const ushort slocVersion = 5;

public static string CurrentVersion = "5.1.0";
public static string CurrentVersion = "5.1.1";

#region Reader Declarations

Expand Down

0 comments on commit 16a1e21

Please sign in to comment.