-
Notifications
You must be signed in to change notification settings - Fork 383
Support major.minor version format in global.json runtimes #16420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/support-major-minor-global-json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9332d89
Initial plan
Copilot 3751172
Add support for major.minor version format in global.json runtimes
Copilot 920366b
Update eng/common scripts to support -channel parameter
Copilot 97dc47d
Fix Exit command in tools.ps1 to use return
Copilot 9b711e9
Final summary - all changes complete
Copilot 15bcdb5
Remove build artifact nuget.exe and add to gitignore
Copilot 14016c4
Revert .gitignore change as requested
Copilot a9584e4
Use regex for two-part version detection as requested
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Microsoft.DotNet.Arcade.Sdk.Tests/InstallDotNetCoreTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Reflection; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.DotNet.Arcade.Sdk.Tests | ||
| { | ||
| public class InstallDotNetCoreTests | ||
| { | ||
| [Theory] | ||
| [InlineData("8.0", true)] | ||
| [InlineData("10.0", true)] | ||
| [InlineData("3.1", true)] | ||
| [InlineData("8.0.22", false)] | ||
| [InlineData("10.0.1", false)] | ||
| [InlineData("8.0.0-preview.1", false)] | ||
| [InlineData("", false)] | ||
| [InlineData(null, false)] | ||
| [InlineData("8", false)] | ||
| [InlineData("8.0.1.2", false)] | ||
| [InlineData("v8.0", false)] | ||
| [InlineData("8.x", false)] | ||
| public void IsTwoPartVersion_DetectsCorrectFormat(string versionString, bool expected) | ||
| { | ||
| // Use reflection to call the private method | ||
| var task = new InstallDotNetCore(); | ||
| var method = typeof(InstallDotNetCore).GetMethod("IsTwoPartVersion", BindingFlags.NonPublic | BindingFlags.Instance); | ||
|
|
||
| var result = (bool)method.Invoke(task, new object[] { versionString }); | ||
|
|
||
| Assert.Equal(expected, result); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
| using System.Text.Json; | ||
| using System.Text.RegularExpressions; | ||
|
|
||
| namespace Microsoft.DotNet.Arcade.Sdk | ||
| { | ||
|
|
@@ -106,8 +107,16 @@ public override bool Execute() | |
| } | ||
|
|
||
| SemanticVersion version = null; | ||
| string channel = null; | ||
|
|
||
| // Check if the version is in major.minor format (e.g., "8.0", "10.0") | ||
| // This format should use the -channel parameter instead of -version | ||
| if (IsTwoPartVersion(item.Key)) | ||
| { | ||
| channel = item.Key; | ||
| } | ||
| // Try to parse version | ||
| if (!SemanticVersion.TryParse(item.Key, out version)) | ||
| else if (!SemanticVersion.TryParse(item.Key, out version)) | ||
| { | ||
| var propertyName = item.Key.Trim(s_keyTrimChars); | ||
|
|
||
|
|
@@ -123,9 +132,12 @@ public override bool Execute() | |
| } | ||
| } | ||
|
|
||
| if (version != null) | ||
| if (version != null || channel != null) | ||
| { | ||
| string arguments = $"-runtime \"{runtimeItem.Key}\" -version \"{version.ToNormalizedString()}\""; | ||
| string arguments = channel != null | ||
| ? $"-runtime \"{runtimeItem.Key}\" -channel \"{channel}\"" | ||
| : $"-runtime \"{runtimeItem.Key}\" -version \"{version.ToNormalizedString()}\""; | ||
|
|
||
| if (!string.IsNullOrEmpty(architecture)) | ||
| { | ||
| arguments += $" -architecture {architecture}"; | ||
|
|
@@ -204,6 +216,21 @@ private string GetArchitecture(string architecture) | |
| return null; | ||
| } | ||
|
|
||
| /* | ||
| * Checks if a version string is in major.minor format (e.g., "8.0", "10.0"). | ||
| * Returns true if the version has exactly two numeric parts separated by a dot. | ||
| */ | ||
| private bool IsTwoPartVersion(string versionString) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(versionString)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Please use a regex for this detection.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to use regex pattern |
||
| { | ||
| return false; | ||
| } | ||
|
|
||
| // Match exactly two numeric parts separated by a dot | ||
| return Regex.IsMatch(versionString, @"^\d+\.\d+$"); | ||
| } | ||
|
|
||
| /* | ||
| * Parses a json token of this format | ||
| * { (runtime): [(version), ..., (version)] } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mconnew would this be a problem for you? it means we'd run dotnet-install.ps1 everytime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akoeplinger, would that only be when running restore? If running
build -builddoesn't trigger this, that would be fine.