Skip to content

Better error when workload set version uses package version format#54929

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/detect-invalid-version-format
Draft

Better error when workload set version uses package version format#54929
Copilot wants to merge 3 commits into
mainfrom
copilot/detect-invalid-version-format

Conversation

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Users occasionally specify a workload set version in the internal NuGet package format (e.g. 10.105.0, 11.100.0-preview.5.26309.3) instead of the user-facing format (10.0.105, 11.0.100-preview.5). Previously this produced a confusing NuGet "package not found" failure; now it produces a clear error with the corrected version.

The user-facing format always has 0 as the minor component — a non-zero minor is the diagnostic signal.

Changes

  • WorkloadSetVersion.cs — adds IsWorkloadSetVersionInPackageVersionFormat(string, out string?) which detects the wrong format and computes the corrected version string (8.203.18.0.203.1, 11.100.0-preview.5.26309.311.0.100-preview.5.26309.3)
  • WorkloadSetVersion.Validation.cs — deleted; was an orphaned file with conflicting duplicate definitions not compiled into any project
  • InstallingWorkloadCommand.cs — validates both --version command-line values and workloadVersion from global.json, throwing early with a helpful message
  • WorkloadSearchVersionsCommandDefinition.cs — extends the existing version argument validator to emit the specific error instead of a generic "unrecognized argument"
  • CliCommandStrings.resx / CommandDefinitionStrings.resx — two new error strings; all XLF files regenerated

Error messages

'10.105.0' is not a valid workload set version. The workload set version should have the form
'major.0.patch' (for example, '10.0.105'). Did you mean '10.0.105'?

'11.100.0-preview.5.26309.3' is not a valid workload set version. ... Did you mean
'11.0.100-preview.5.26309.3'? (Specified in 'path/to/global.json')

Copilot AI and others added 2 commits June 22, 2026 21:11
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
…ment

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI changed the title Detect wrong workload set version format with helpful error message Better error when workload set version uses package version format Jun 22, 2026
Copilot AI requested a review from marcpopMSFT June 22, 2026 21:13
@marcpopMSFT

Copy link
Copy Markdown
Member

@copilot Fix the build errors

/mnt/vss/_work/1/s/src/Common/WorkloadSetVersion.cs(70,34): error CS0518: Predefined type 'System.Range' is not defined or imported [/mnt/vss/_work/1/s/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj]
/mnt/vss/_work/1/s/src/Common/WorkloadSetVersion.cs(70,34): error CS0518: Predefined type 'System.Index' is not defined or imported [/mnt/vss/_work/1/s/src/Resolvers/Microsoft.DotNet.MSBuildSdkResolver/Microsoft.DotNet.MSBuildSdkResolver.csproj]
/mnt/vss/_work/1/s/test/Microsoft.DotNet.Cli.Utils.Tests/TransientSdkResolutionErrorDetectorTests.cs(8,10): error CS0246: The type or namespace name 'FactAttribute' could not be found (are you missing a using directive or an assembly reference?) [/mnt/vss/_work/1/s/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj]
/mnt/vss/_work/1/s/test/Microsoft.DotNet.Cli.Utils.Tests/TransientSdkResolutionErrorDetectorTests.cs(8,10): error CS0246: The type or namespace name 'Fact' could not be found (are you missing a using directive or an assembly reference?) [/mnt/vss/_work/1/s/test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj]

…convert xUnit tests to MSTest

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>

Copilot AI commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Fix the build errors

/mnt/vss/_work/1/s/src/Common/WorkloadSetVersion.cs(70,34): error CS0518: Predefined type 'System.Range' is not defined or imported [/mnt/vss/_work/1/s/src/Resolver...

Fixed in the latest commit:

  1. WorkloadSetVersion.cs — replaced the C# range indexer [sections[0].Length..] with Substring(sections[0].Length) for net472 compatibility (both System.Range and System.Index are unavailable on full framework). Verified the Microsoft.DotNet.MSBuildSdkResolver project now builds cleanly.

  2. TransientSdkResolutionErrorDetectorTests.cs — converted from xUnit [Fact] to MSTest [TestClass]/[TestMethod] to match the project's MSTest.Sdk configuration. Verified the Microsoft.DotNet.Cli.Utils.Tests project now builds cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants