Skip to content

Add version management commands (check, list, update)#46

Open
jfversluis wants to merge 2 commits intomainfrom
feature/version-commands
Open

Add version management commands (check, list, update)#46
jfversluis wants to merge 2 commits intomainfrom
feature/version-commands

Conversation

@jfversluis
Copy link
Copy Markdown
Member

Summary

Ports functionality from jfversluis/maui-version into the maui CLI as subcommands of maui version.

New Commands

Command Description
maui version check Show installed MAUI package versions in a project, resolve $(MauiVersion)
maui version list Query available versions from stable or nightly NuGet feeds
maui version update --latest Update to latest stable (sets $(MauiVersion))
maui version update --latest-nightly Switch to latest nightly build
maui version update --version <v> Install a specific version (e.g. from a PR build)

Examples

# Check what version your project uses
maui version check

# List available nightly versions
maui version list --channel nightly

# Switch to nightly + set up NuGet.config
maui version update --latest-nightly --nuget-config

# Install a specific PR build version
maui version update --version 10.0.0-preview.5.25180.1

# Preview changes without modifying files
maui version update --latest --dry-run

Implementation

  • NuGetVersionService: Queries nuget.org (stable) and maui-nightly AzDO feed using NuGet.Protocol
  • ProjectVersionService: Parses csproj XML, replaces package versions, runs dotnet restore, manages NuGet.config
  • Follows existing patterns: partial class command groups (like AndroidCommands), IOutputFormatter for JSON/Spectre output, global --json/--dry-run support
  • maui version (bare) still shows CLI version info as before

Dependencies

  • Adds NuGet.Protocol 6.13.1 to the CLI project

Tests

All 119 existing tests pass. New service tests to follow.

Port functionality from jfversluis/maui-version into the maui CLI as
subcommands of 'maui version':

- maui version check: inspect MAUI package versions in a project,
  resolve $(MauiVersion) via workload info, detect version mismatches
- maui version list: query available versions from stable or nightly
  NuGet feeds with prerelease filtering
- maui version update: switch MAUI packages to latest stable,
  latest nightly, or a specific version (e.g. PR builds);
  optional --nuget-config to set up the nightly feed

New services:
- NuGetVersionService: queries nuget.org and maui-nightly AzDO feed
  using NuGet.Protocol
- ProjectVersionService: csproj XML parsing, version replacement,
  dotnet add package integration, NuGet.config management

Adds NuGet.Protocol 6.13.1 dependency. All 119 existing tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 31, 2026 14:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds maui version subcommands to the CLI to inspect and manage .NET MAUI package versions in a project, including querying NuGet feeds and updating project references.

Changes:

  • Introduces maui version check, maui version list, and maui version update commands under a new VersionCommands command group.
  • Adds NuGetVersionService (NuGet feed querying) and ProjectVersionService (project parsing/updating + dotnet operations).
  • Updates CLI docs and central package management to include NuGet.Protocol.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/Cli/README.md Documents the new maui version subcommands and examples.
src/Cli/Microsoft.Maui.Cli/Services/ProjectVersionService.cs New service to detect/update MAUI package versions and manage NuGet.config.
src/Cli/Microsoft.Maui.Cli/Services/NuGetVersionService.cs New service to query stable/nightly feeds for MAUI package versions.
src/Cli/Microsoft.Maui.Cli/ServiceConfiguration.cs Registers the new version services with DI.
src/Cli/Microsoft.Maui.Cli/Program.cs Switches root command registration to VersionCommands.
src/Cli/Microsoft.Maui.Cli/Microsoft.Maui.Cli.csproj Adds NuGet.Protocol package reference.
src/Cli/Microsoft.Maui.Cli/Commands/VersionCommands.Update.cs Implements maui version update behavior/options.
src/Cli/Microsoft.Maui.Cli/Commands/VersionCommands.List.cs Implements maui version list behavior/options.
src/Cli/Microsoft.Maui.Cli/Commands/VersionCommands.Check.cs Implements maui version check behavior/options.
src/Cli/Microsoft.Maui.Cli/Commands/VersionCommand.cs Converts existing maui version into a command group + subcommands.
eng/Versions.props Adds NuGetProtocolVersion property.
Directory.Packages.props Pins NuGet.Protocol via central package management.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Handle implicit versions (no Version attribute) in check/update
- Check process exit codes and throw on failure
- Make EnsureNuGetConfig idempotent (list sources, update if exists)
- Preserve file content (split on \n, write back raw)
- Dispose SourceCacheContext with using
- Sort versions explicitly with OrderBy
- Resolve services from DI instead of direct instantiation
- Add new services to CreateTestServiceProvider
- Validate --channel (stable/nightly only)
- Validate --take > 0
- Only update Compatibility package if already referenced
- Track HasControlsReference/HasCompatibilityReference in version info

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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