Fix Visual Studio project GUIDs getting randomized during regeneration

This commit is contained in:
2023-09-27 20:16:46 +03:00
parent 0c00dc20a2
commit 22e5afdb6f
10 changed files with 59 additions and 41 deletions

View File

@@ -55,7 +55,7 @@ namespace Flax.Build.Projects.VisualStudio
}
/// <inheritdoc />
public override void GenerateProject(Project project)
public override void GenerateProject(Project project, string solutionPath)
{
var vcProjectFileContent = new StringBuilder();
var vcFiltersFileContent = new StringBuilder();
@@ -67,6 +67,13 @@ namespace Flax.Build.Projects.VisualStudio
var projectDirectory = Path.GetDirectoryName(project.Path);
var filtersDirectory = project.SourceFolderPath;
// Try to reuse the existing project guid from existing files
vsProject.ProjectGuid = GetProjectGuid(vsProject.Path, vsProject.Name);
if (vsProject.ProjectGuid == Guid.Empty)
vsProject.ProjectGuid = GetProjectGuid(solutionPath, vsProject.Name);
if (vsProject.ProjectGuid == Guid.Empty)
vsProject.ProjectGuid = Guid.NewGuid();
// Header
vcProjectFileContent.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
vcProjectFileContent.AppendLine(string.Format("<Project DefaultTargets=\"Build\" ToolsVersion=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">", projectFileToolVersion));