summaryrefslogtreecommitdiffstats
path: root/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-11 10:16:01 +0200
committerGitHub <noreply@github.com>2020-05-11 10:16:01 +0200
commit54bb4cb6d66237e9b173d879fca50eefa7cbf6fa (patch)
treeaa53f4218b27a78450167a0cb339ec2c20fd5a23 /modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
parent77a9334c58e5e01123372218b45ba633d739c75f (diff)
parentdcf1dc4fe02bbebe86cb13168596a1d3d1d67371 (diff)
downloadredot-engine-54bb4cb6d66237e9b173d879fca50eefa7cbf6fa.tar.gz
Merge pull request #38650 from neikeq/dotnet-cli-support
C#: Support for building with the dotnet CLI
Diffstat (limited to 'modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs26
1 files changed, 23 insertions, 3 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
index a0356d0f49..069a1edaa3 100644
--- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
+++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectUtils.cs
@@ -173,7 +173,7 @@ namespace GodotTools.ProjectEditor
void AddPropertyIfNotPresent(string name, string condition, string value)
{
if (root.PropertyGroups
- .Any(g => (g.Condition == string.Empty || g.Condition.Trim() == condition) &&
+ .Any(g => (string.IsNullOrEmpty(g.Condition) || g.Condition.Trim() == condition) &&
g.Properties
.Any(p => p.Name == name &&
p.Value == value &&
@@ -264,7 +264,7 @@ namespace GodotTools.ProjectEditor
bool hasGodotProjectGeneratorVersion = false;
bool foundOldConfiguration = false;
- foreach (var propertyGroup in root.PropertyGroups.Where(g => g.Condition == string.Empty))
+ foreach (var propertyGroup in root.PropertyGroups.Where(g => string.IsNullOrEmpty(g.Condition)))
{
if (!hasGodotProjectGeneratorVersion && propertyGroup.Properties.Any(p => p.Name == "GodotProjectGeneratorVersion"))
hasGodotProjectGeneratorVersion = true;
@@ -280,7 +280,7 @@ namespace GodotTools.ProjectEditor
if (!hasGodotProjectGeneratorVersion)
{
- root.PropertyGroups.First(g => g.Condition == string.Empty)?
+ root.PropertyGroups.First(g => string.IsNullOrEmpty(g.Condition))?
.AddProperty("GodotProjectGeneratorVersion", Assembly.GetExecutingAssembly().GetName().Version.ToString());
project.HasUnsavedChanges = true;
}
@@ -348,5 +348,25 @@ namespace GodotTools.ProjectEditor
MigrateConfigurationConditions("Tools", "Debug"); // Must be last
}
}
+
+ public static void EnsureHasNugetNetFrameworkRefAssemblies(MSBuildProject project)
+ {
+ var root = project.Root;
+
+ bool found = root.ItemGroups.Any(g => string.IsNullOrEmpty(g.Condition) && g.Items.Any(
+ item => item.ItemType == "PackageReference" && item.Include == "Microsoft.NETFramework.ReferenceAssemblies"));
+
+ if (found)
+ return;
+
+ var frameworkRefAssembliesItem = root.AddItem("PackageReference", "Microsoft.NETFramework.ReferenceAssemblies");
+
+ // Use metadata (child nodes) instead of attributes for the PackageReference.
+ // This is for compatibility with 3.2, where GodotTools uses an old Microsoft.Build.
+ frameworkRefAssembliesItem.AddMetadata("Version", "1.0.0");
+ frameworkRefAssembliesItem.AddMetadata("PrivateAssets", "All");
+
+ project.HasUnsavedChanges = true;
+ }
}
}