Skip to content

Commit

Permalink
Fixed renaming (creating new web) projects to include a few more files.
Browse files Browse the repository at this point in the history
fixes #1441
  • Loading branch information
vchelaru committed Aug 11, 2024
1 parent 8538256 commit 799971c
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions FRBDK/Glue/NpcWpfLib/Managers/ProjectCreationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ public static void RenameProject(string newProjectName, string oldProjectName, s
newNamespace = newNamespace ?? newProjectName;
if(oldProjectName != newNamespace)
{
UpdateNamespaces(projectRootDirectory, oldProjectName,
newNamespace);
UpdateNamespaces(projectRootDirectory, oldProjectName, newNamespace);
}

}
Expand Down Expand Up @@ -431,6 +430,9 @@ private static void RenameFiles(string unpackDirectory, string stringToReplace,
filesToReplace.AddRange(FileManager.GetAllFilesInDirectory(
unpackDirectory, "pfx"));

filesToReplace.AddRange(FileManager.GetAllFilesInDirectory(
unpackDirectory, "mgcb"));


foreach (string fileName in filesToReplace)
{
Expand Down Expand Up @@ -619,6 +621,10 @@ private static void UpdateNamespaces(string unpackDirectory, string stringToRepl
string newProjectReference = $@"<ProjectReference Include=""..\{stringToReplaceWith}Content\{stringToReplaceWith}Content.contentproj"">";
contents = contents.Replace(originalProjectReference, newProjectReference);

string originalMgcb = $@"<KniContentReference Include=""Content\{stringToReplace}Content.mgcb"" />";
string newMgcb = $@"<KniContentReference Include=""Content\{stringToReplaceWith}Content.mgcb"" />";
contents = contents.Replace(originalMgcb, newMgcb);

System.IO.File.WriteAllText(fileName, contents, Encoding.UTF8);
}

Expand Down Expand Up @@ -700,8 +706,38 @@ private static void UpdateNamespaces(string unpackDirectory, string stringToRepl

contents = contents.Replace(whatToSearchFor, replacement);

if(contents.Contains($"<PageTitle>{stringToReplace}</PageTitle>"))
{
whatToSearchFor = $"<PageTitle>{stringToReplace}</PageTitle>";
replacement = $"<PageTitle>{stringToReplaceWith}</PageTitle>";

contents = contents.Replace(whatToSearchFor, replacement);
}

FileManager.SaveText(contents, fileName);
}
#endregion

#region launchSettings.json

filesToFix.Clear();
filesToFix.AddRange(FileManager.GetAllFilesInDirectory(unpackDirectory, "json"));
foreach(var fileName in filesToFix)
{
if (fileName.ToLowerInvariant().EndsWith("launchsettings.json") == false)
{
continue;
}

string contents = FileManager.FromFileText(fileName);
string whatToSearchFor = "\"" + stringToReplace + "\": {";
string replacement = "\"" + stringToReplaceWith + "\": {";

contents = contents.Replace(whatToSearchFor, replacement);

FileManager.SaveText(contents, fileName);
}

#endregion
}

Expand Down

0 comments on commit 799971c

Please sign in to comment.