Skip to content

Commit

Permalink
Write global.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkl committed Dec 7, 2022
1 parent 9505fbb commit 6c5bddf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ public abstract class TestBase : MSBuildTestBase, IDisposable
protected TestBase()
{
TestRootPath = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())).FullName;
WriteGlobalJson();
}

public string DotNetSdkVersion
{
get =>
#if NETCOREAPP3_1
"3.1.100";
#elif NET6_0
"6.0.100";
#elif NET7_0 || NETFRAMEWORK
"7.0.100";
#else
Unknown target framework!
#endif
}

public string TargetFramework
Expand Down Expand Up @@ -63,5 +78,17 @@ protected string GetTempProjectPath(string extension = null)

return Path.Combine(tempDirectoryInfo.FullName, $"{Path.GetRandomFileName()}{extension ?? string.Empty}");
}

private void WriteGlobalJson()
{
File.WriteAllText(
Path.Combine(TestRootPath, "global.json"),
$@"{{
""sdk"": {{
""version"": ""{DotNetSdkVersion}"",
""rollForward"": ""latestMinor""
}}
}}");
}
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "8.3",
"version": "9.0",
"assemblyVersion": "1.0",
"buildNumberOffset": -1,
"nugetPackageVersion": {
Expand Down

0 comments on commit 6c5bddf

Please sign in to comment.