blob: cdac9acb259b8d56b5feaabc88f86522af144579 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using System;
using Microsoft.Build.Construction;
namespace GodotTools.ProjectEditor
{
public sealed class MSBuildProject
{
internal ProjectRootElement Root { get; set; }
public bool HasUnsavedChanges { get; set; }
public void Save() => Root.Save();
public MSBuildProject(ProjectRootElement root)
{
Root = root;
}
}
public static class ProjectUtils
{
public static MSBuildProject Open(string path)
{
var root = ProjectRootElement.Open(path);
return root != null ? new MSBuildProject(root) : null;
}
public static void MigrateToProjectSdksStyle(MSBuildProject project, string projectName)
{
var origRoot = project.Root;
if (!string.IsNullOrEmpty(origRoot.Sdk))
return;
project.Root = ProjectGenerator.GenGameProject(projectName);
project.Root.FullPath = origRoot.FullPath;
project.HasUnsavedChanges = true;
}
public static void EnsureGodotSdkIsUpToDate(MSBuildProject project)
{
var root = project.Root;
string godotSdkAttrValue = ProjectGenerator.GodotSdkAttrValue;
if (!string.IsNullOrEmpty(root.Sdk) && root.Sdk.Trim().Equals(godotSdkAttrValue, StringComparison.OrdinalIgnoreCase))
return;
root.Sdk = godotSdkAttrValue;
project.HasUnsavedChanges = true;
}
}
}
|