Skip to content

Commit

Permalink
Tests: read and modify our own global.json instead of the manual sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Dec 11, 2024
1 parent bf2e5d4 commit 0ae40b5
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions Cesium.Sdk.Tests/SdkTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Nodes;
using Cesium.Solution.Metadata;
using Cesium.TestFramework;
using Xunit.Abstractions;
Expand Down Expand Up @@ -146,18 +147,14 @@ private static void EmitNuGetConfig(string configFilePath, string packageSourceP

private static void EmitGlobalJson(string globalJsonPath, string packageVersion)
{
File.WriteAllText(globalJsonPath, $$"""
{
"sdk": {
"version": "9.0.0",
"rollForward": "latestFeature",
"allowPrerelease": false
},
"msbuild-sdks": {
"Cesium.Sdk" : "{{packageVersion}}"
}
}
""");
var actualGlobalJson = Path.Combine(SolutionMetadata.SourceRoot, "global.json");
var globalConfig = JsonNode.Parse(File.ReadAllText(actualGlobalJson))!;
globalConfig["msbuild-sdks"] = new JsonObject([new KeyValuePair<string, JsonNode?>("Cesium.Sdk", packageVersion)]);
var content = globalConfig.ToJsonString(new JsonSerializerOptions()
{
WriteIndented = true
});
File.WriteAllText(globalJsonPath, content);
}

private static void CopyDirectoryRecursive(string source, string target)
Expand Down

0 comments on commit 0ae40b5

Please sign in to comment.