Skip to content

Commit

Permalink
Fixes 3224: Add rollForward option to global.json generated by 'dotne…
Browse files Browse the repository at this point in the history
…t new globaljson'
  • Loading branch information
DavidKarlas committed Aug 11, 2021
1 parent 82c5068 commit 391c2ae
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"longName": "sdk-version",
"shortName": ""
},
"RollForward": {
"longName": "roll-forward",
"shortName": ""
},
"dotnet-cli-version": {
"isHidden": "true"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,52 @@
"fallbackVariableName": "dotnet-cli-version"
},
"replaces": "SDK_VERSION"
},
"RollForward": {
"type": "parameter",
"description": "The roll-forward policy to use when selecting an SDK version.",
"displayName": "Roll Forward",
"replaces": "ROLL_FORWARD_VALUE",
"defaultValue": "",
"datatype": "choice",
"choices": [
{
"choice": "patch",
"description": "Uses the specified version.\nIf not found, rolls forward to the latest patch level.\nIf not found, fails.\nThis value is the legacy behavior from the earlier versions of the SDK."
},
{
"choice": "feature",
"description": "Uses the latest patch level for the specified major, minor, and feature band.\nIf not found, rolls forward to the next higher feature band within the same major/minor and uses the latest patch level for that feature band.\nIf not found, fails."
},
{
"choice": "minor",
"description": "Uses the latest patch level for the specified major, minor, and feature band.\nIf not found, rolls forward to the next higher feature band within the same major/minor version and uses the latest patch level for that feature band.\nIf not found, rolls forward to the next higher minor and feature band within the same major and uses the latest patch level for that feature band.\nIf not found, fails."
},
{
"choice": "major",
"description": "Uses the latest patch level for the specified major, minor, and feature band.\nIf not found, rolls forward to the next higher feature band within the same major/minor version and uses the latest patch level for that feature band.\nIf not found, rolls forward to the next higher minor and feature band within the same major and uses the latest patch level for that feature band.\nIf not found, rolls forward to the next higher major, minor, and feature band and uses the latest patch level for that feature band.\nIf not found, fails."
},
{
"choice": "latestPatch",
"description": "Uses the latest installed patch level that matches the requested major, minor, and feature band with a patch level and that is greater or equal than the specified value.\nIf not found, fails."
},
{
"choice": "latestFeature",
"description": "Uses the highest installed feature band and patch level that matches the requested major and minor with a feature band and patch level that is greater or equal than the specified value.\nIf not found, fails."
},
{
"choice": "latestMinor",
"description": "Uses the highest installed minor, feature band, and patch level that matches the requested major with a minor, feature band, and patch level that is greater or equal than the specified value.\nIf not found, fails."
},
{
"choice": "latestMajor",
"description": "Uses the highest installed .NET SDK with a version that is greater or equal than the specified value.\nIf not found, fail."
},
{
"choice": "disable",
"description": "Doesn't roll forward. Exact match required."
}
]
}
},
"postActions": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"sdk": {
//#if (RollForward!="")
"rollForward": "ROLL_FORWARD_VALUE",
//#endif
"version": "SDK_VERSION"
}
}
40 changes: 40 additions & 0 deletions test/dotnet-new3.UnitTests/CommonTemplatesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,46 @@ public void AllCommonItemsCreate(string expectedTemplateName, string templateSho
Directory.Delete(workingDir, true);
}

[Theory]
[InlineData(
@"{
""sdk"": {
""version"": ""5.0.200""
}
}",
"globaljson",
"--sdk-version",
"5.0.200")]
[InlineData(
@"{
""sdk"": {
""rollForward"": ""major""
""version"": ""5.0.200""
}
}",
"globaljson",
"--sdk-version",
"5.0.200",
"--roll-forward",
"major")]
public void GlobalJsonTests( string expectedContent, params string[] parameters)
{
string workingDir = TestUtils.CreateTemporaryFolder();

new DotnetNewCommand(_log, parameters)
.WithCustomHive(_fixture.HomeDirectory)
.WithWorkingDirectory(workingDir)
.Execute()
.Should()
.ExitWith(0)
.And.NotHaveStdErr()
.And.HaveStdOut($@"The template ""global.json file"" was created successfully.");

string globalJsonConent = File.ReadAllText(Path.Combine(workingDir, "global.json"));
Assert.Same(expectedContent.Replace("\r\n", "\n"), globalJsonConent.Replace("\r\n", "\n"));
Directory.Delete(workingDir, true);
}

#region Project templates language features tests

/// <summary>
Expand Down

0 comments on commit 391c2ae

Please sign in to comment.