Skip to content

CPM Support to switch-to-nightly- #26109 - #26146

Open
gizemfirat wants to merge 2 commits into
rel-10.7from
gizem/switch-to-nightly
Open

CPM Support to switch-to-nightly- #26109#26146
gizemfirat wants to merge 2 commits into
rel-10.7from
gizem/switch-to-nightly

Conversation

@gizemfirat

Copy link
Copy Markdown
Contributor

Extend switch-to-nightly with --include and --exclude-packages options to optionally update Central Package Management files (like Directory.Packages.props) alongside regular project/package updates. The updater now resolves the nightly ABP version once, updates PackageVersion Include="Volo.*" entries with exclusion and LeptonX/Studio safeguards, and logs/continues on MyGet or file-write failures. Also fixes .npmrc registry appending to insert a newline before the added registry entry.

Test Scenario: abp switch-to-nightly --include / --exclude-packages

Prerequisites

A solution using Central Package Management (Directory.Packages.props with ManagePackageVersionsCentrally=true).
Run the CLI from source: dotnet run --project framework/src/Volo.Abp.Cli -- switch-to-nightly -d [options]
Default behavior is unchanged (no --include)
abp switch-to-nightly -d

Test Scenario: abp switch-to-nightly --include / --exclude-packages

Prerequisites

A solution using Central Package Management (Directory.Packages.props with ManagePackageVersionsCentrally=true).
Run the CLI from source: dotnet run --project framework/src/Voly -d [options]
Default behavior is unchanged (no --include)
abp switch-to-nightly -d

Expected: Directory.Packages.props is not modified at all. ConckageId} uses central package management. Skipped!" for everyversion-less PackageReference, exactly as before this change.
--include updates central package versions
abp switch-to-nightly -d --include Directory.Packages.props --exclude-packages
Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX,Volo.Abp.Studio.Client.

Expected:
Every entry (except excluded ones and LeptonX/Studio) is updated to the resolved nightly version of Volo.Abp.Core.
Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX and Volo.Abp.Studio.Client.AspNetCore are never touched, even without listing them in --exclude-packages (hardcoded skip).
Packages listed in --exclude-packages are left untouched.
Non-Volo.* packages (e.g. Newtonsoft.Json) are untouched.
File formatting/indentation is preserved (diff shows only Ve).
Missing --include file does not crash the run
abp switch-to-nightly -d --include DoesNotExist.props

Expected: A warning is logged ("--include file not found, skipletes successfully (exit code 0), and the rest of the solution'sregular package/npm updates still proceed normally.
Idempotency
Run step 2's command twice in a row.

Expected: The second run produces no diff at all — the file is already at the target version.
No race condition on shared CPM files
Run against a solution where multiple .csproj files reference thps.

Expected: The file remains valid XML after the run, and this is guaranteed structurally — the --include pass only starts after the solution's parallel
(Task.WaitAll) per-project update has fully completed, so no cthe shared file.
Transient MyGet failure doesn't abort the whole run
Simulate a network failure to MyGet (e.g. temporarily block www.abp.io).

Expected: A warning is logged ("Could not resolve the latest Volo.Abp.Core nightly version..."), the --include step is skipped for this run, but NuGet source registration and regular PackageReference/npm updates still complete normally.

Extend `switch-to-nightly` with optional `--include` and `--exclude-packages` arguments so central package management files like `Directory.Packages.props` can be updated alongside regular project references. The updater now applies the latest ABP nightly version to `PackageVersion` entries, while still skipping LeptonX and Studio packages and avoiding aborting the whole command on MyGet or file-write issues. Also fix npm registry updates to append the Volosoft registry on a new line.
Improves CLI package update reliability when using `--include` by exiting that pass early if the latest `Volo.Abp.Core` nightly version cannot be resolved (either due to an exception or an empty result), with clear warning logs. Also switches one file reader to use the updater’s `DefaultEncoding` instead of `Encoding.Default` for consistent encoding behavior.
@gizemfirat gizemfirat self-assigned this Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The CPM updater introduces avoidable public API surface and has a preventable in-place rewrite risk (truncate-before-write) that can be mitigated with small, targeted adjustments.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends the switch-to-nightly CLI workflow to optionally update Central Package Management (CPM) files (e.g., Directory.Packages.props) via new --include and --exclude-packages options, while preserving existing default behavior when --include is not provided.

Changes:

  • Added CPM-aware update pass that updates <PackageVersion Include="Volo.*" Version="..."> entries (with LeptonX/Studio safeguards + explicit exclusions) after the standard per-project/package updates complete.
  • Resolved the nightly version once (anchored to Volo.Abp.Core) and reused it across all included CPM file updates; logs and continues on MyGet resolution failures and file update failures.
  • Adjusted .npmrc registry appending to insert a newline before the added registry entry.
File summaries
File Description
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs Adds CPM file update routine and shared package-type helpers (LeptonX/Studio detection), plus exposes MyGet version lookup to the switcher.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs Plumbs --include / --exclude-packages through switch-to-nightly, resolves nightly version once, and runs a sequential CPM update pass after solution/project updates.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs Ensures .npmrc appends the additional registry entry on a new line.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/SwitchToNightlyCommand.cs Updates CLI usage text to document the new options.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +452 to +459
fs.Seek(0, SeekOrigin.Begin);
fs.SetLength(0);

using (var sw = new StreamWriter(fs, DefaultEncoding))
{
await sw.WriteAsync(doc.OuterXml);
await sw.FlushAsync();
}
Comment on lines +296 to 306
foreach (var includeFile in includeFiles)
{
var resolvedPath = Path.IsPathRooted(includeFile)
? includeFile
: Path.Combine(baseFolder, includeFile);

await _nugetPackagesVersionUpdater.UpdateCentralPackageVersionsAsync(
resolvedPath,
latestVersionFromMyGet,
excludedPackages);
}
Comment on lines 133 to 136
if (!fileContent.Contains(volosoftRegistry))
{
fileContent += volosoftRegistry;
fileContent += Environment.NewLine + volosoftRegistry;
}
/// versions kept in sync. Not invoked unless a caller (e.g. the switch-to-nightly --include
/// option) explicitly requests it.
/// </summary>
public async Task UpdateCentralPackageVersionsAsync(
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.

3 participants