Skip to content

Add CPM include support to switch-to-nightly - #26109

Open
gizemfirat wants to merge 4 commits into
devfrom
issue-switch-to-nightly-cpm-support
Open

Add CPM include support to switch-to-nightly#26109
gizemfirat wants to merge 4 commits into
devfrom
issue-switch-to-nightly-cpm-support

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]
  1. 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]
  1. 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.
  1. --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).
  1. 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.
  1. 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.
  1. 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.
  1. 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 `--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.
@gizemfirat gizemfirat self-assigned this Aug 28, 2026
@gizemfirat
gizemfirat marked this pull request as ready for review August 28, 2026 13:45
Copilot AI lite review requested due to automatic review settings August 28, 2026 13:45

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.

Pull request overview

Extends the switch-to-nightly flow in the ABP CLI to optionally update Central Package Management (CPM) version declarations (e.g., Directory.Packages.props) alongside existing per-project PackageReference and npm updates.

Changes:

  • Add --include and --exclude-packages parsing to run an opt-in CPM update pass after the nightly switch completes.
  • Implement CPM <PackageVersion Include="Volo.*" Version="..."> stamping with LeptonX/Studio safeguards and per-package exclusions.
  • Fix .npmrc registry appending to always insert a newline before the added entry.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs Adds CPM props updating and refactors LeptonX/Studio detection helpers; exposes MyGet version resolution for reuse.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/PackagePreviewSwitcher.cs Wires --include/--exclude-packages into switch-to-nightly and runs the CPM pass after solution/project updates.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs Ensures .npmrc registry appends start 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.
Suppressed comments (1)

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/VoloNugetPackagesVersionUpdater.cs:455

  • The file is read with BOM detection, but the write uses DefaultEncoding instead of the detected sr.CurrentEncoding. This can change the file’s encoding/BOM unexpectedly when updating central package files. Write back using sr.CurrentEncoding to preserve the original encoding as much as possible.
                    using (var sw = new StreamWriter(fs, DefaultEncoding))

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

Comment on lines +265 to +279
string latestVersionFromMyGet;
try
{
latestVersionFromMyGet = await _nugetPackagesVersionUpdater.GetLatestVersionFromMyGet("Volo.Abp.Core");
}
catch (Exception ex)
{
// Don't let a transient MyGet failure abort the whole switch-to-nightly run
// (source registration / regular PackageReference updates below must still
// proceed for every solution/project) - just skip the --include pass.
Logger.LogWarning(ex, "Could not resolve the latest Volo.Abp.Core nightly version; --include files will be skipped for this run.");
latestVersionFromMyGet = null;
}

return (includeFiles, excludedPackages, latestVersionFromMyGet);
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 107 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.77%. Comparing base (18dcd77) to head (c9ec438).

Files with missing lines Patch % Lines
...ectModification/VoloNugetPackagesVersionUpdater.cs 0.00% 59 Missing ⚠️
.../Cli/ProjectModification/PackagePreviewSwitcher.cs 0.00% 45 Missing ⚠️
...re/Volo/Abp/Cli/Commands/SwitchToNightlyCommand.cs 0.00% 2 Missing ⚠️
.../Abp/Cli/ProjectModification/NpmPackagesUpdater.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #26109      +/-   ##
==========================================
- Coverage   49.80%   49.77%   -0.04%     
==========================================
  Files        3833     3833              
  Lines      134158   134259     +101     
  Branches    10169    10187      +18     
==========================================
+ Hits        66820    66830      +10     
- Misses      65316    65408      +92     
+ Partials     2022     2021       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Improve CLI package update behavior when resolving the latest `Volo.Abp.Core` nightly version fails or returns empty: the `--include` pass is now skipped explicitly with a warning while normal project updates continue. Also switch file reading in `VoloNugetPackagesVersionUpdater` to use the shared `DefaultEncoding` instead of `Encoding.Default` for consistent encoding handling.

@yagmurcelk yagmurcelk 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.

H-1 — --include whitespace’li Include’u kaçırır, OuterXml ile bozar

Repo abp CLI
Sev P0
Dosya VoloNugetPackagesVersionUpdater.UpdateCentralPackageVersionsAsync

Beklenen: --include Directory.Packages.props içindeki her Volo.* PackageVersion aynı nightly’ye çekilir. Include değeri tek satır kalır.

Gerçek: XPath //PackageVersion[starts-with(@Include, 'Volo.')] Include \r\nVolo. ile başlarsa eşleşmez. Güncelleme atlanır. Sonra doc.OuterXml CRLF’i attribute’a &#xD;&#xA; yazar.

abp.io kanıtı (Directory.Packages.props):

<PackageVersion Include="&#xD;&#xA;Volo.Abp.BlobStoring.Azure&#xD;&#xA;" Version="10.8.0-preview20260825" />

Komşu paketler 10.8.0-preview20260901. Restore yeşil; obj/project.assets.jsonvolo.abp.blobstoring.azure/10.8.0-preview20260825.

Test: Fixture’da Include’u satır kırıklı yaz, komutu çalıştır. Include entity olmamalı, Version nightly olmalı.

vs-internal geçici düzeltme (CLI’yi kapatmaz):

<PackageVersion Include="Volo.Abp.BlobStoring.Azure" Version="10.8.0-preview20260901" />

H-2 — MyGet hata catch’i sadece --include resolve’da; UpdateSolutionAsync yine throw eder

Repo abp CLI
Sev P1
Dosya PackagePreviewSwitcher

Beklenen (c217d58f2e): MyGet’ten nightly alınamazsa --include skip, uyarı, komut devam.

Gerçek: ResolveNightlyIncludeContextAsync catch ediyor. Hemen ardından UpdateSolutionAsync(..., includePreviews: true) aynı GetLatestVersionFromMyGet’i try/catch’siz çağırır. MyGet throw → tüm switch-to-nightly abort.

Test: MyGet’i blokla. Beklenen: uyarı + devam. Kırılma: unhandled exception.


H-3 — --include yazarken props önce truncate ediliyor

Repo abp CLI
Sev P1
Dosya UpdateCentralPackageVersionsAsync

Beklenen: Yazma/kill/disk full’da dosya eski haliyle kalır veya net error; 0 byte olmaz.

Gerçek: fs.SetLength(0) sonra WriteAsync(doc.OuterXml). Catch error logluyor; truncate write’tan önce. Kod yorumu da bunu söylüyor.

Test: Props’u kilitle veya komutu yazma anında öldür; dosya boyutu 0 olmamalı.


H-4 — Nuget.Web.Tests: iki NuGetPackageTarget, kullanılmayan CLI using

Repo vs-internal
Sev P1
Dosyalar AbpIoPackageAccessibilityChecker_Tests.cs, AbpIoDatabasePackageSearchService_Tests.cs

Beklenen: NuGetPackageTarget tek anlam; CS0104 yok.

Gerçek: Volo.Abp.Cli.Core PackageReference olunca CLI enum derlemeye girdi. İki using var. İsimler FQ yazıldığı için şu an build geçiyor. using Volo.Abp.Cli.ProjectModification; kullanılmıyor.

Test: FQ’yu NuGetPackageTarget.Domain yap → CS0104. Unused using’i sil; Domain enum kalsın.


H-5 — Telemetry.Simulator: HintPath DLL yok (MSB3245)

Repo vs-internal
Sev P1
Dosya Volo.AbpIo.Telemetry.Simulator.csproj

Beklenen: Assembly restore/build ile gelir. CI’de volo bin\Debug yok.

Gerçek:

<HintPath>..\..\..\..\..\volo\abp\account\src\Volo.Abp.Account.Pro.Admin.Application\bin\Debug\net9.0\Volo.Abp.Account.Pro.Admin.Application.dll</HintPath>

Proje net10.0. dotnet buildMSB3245, exit 0. CPM’de aynı paket zaten var (Volo.Abp.Account.Pro.Admin.Application).

Test: volo account’u build etmeden dotnet build Simulator; log’da MSB3245 olmamalı. Simulator’ı çalıştır.


H-6 — Admin: toastr paketi yok; welcome-email / activate toast patlıyor

Repo abp (dev UI cleanup, nightly ile gelir) + vs-internal Admin.Web
Sev P1
ABP c7dedfd522Remove orphan jquery-form and toastr npm packages
Dosyalar Organizations/Index.js, TrialLicenses/Index.js, TrialLicenses/Detail.js

Beklenen: Aksiyon sonrası yeşil toast. Web tarafı abp.notifyabp-toast.js (duruyor).

Gerçek: @abp/toastr nightly’de yok. Yarn sonrası wwwroot/libs/toastr yok. Admin hâlâ toastr.success(...) çağırıyor. Konsol: toastr is not defined. Mail/activate gidebilir; bildirim kırılır.

UI tekrar (admin, F12 Console açık):

  1. Admin’e yetkili user ile gir.
  2. En kolay — Organizations (mail atmadan da görünür):
    Console’a typeof toastr yaz. undefined ise paket yok.
    Sonra: menü Licensing → Organizations → satır Actions → Send Welcome Email → confirm Yes.
    Beklenen: yeşil toast. Gerçek: Uncaught ReferenceError: toastr is not defined.
  3. Trial Licenses: menü Licensing → Trial Licenses.
    • Actions → Send Welcome Email (confirm) → aynı hata.
    • Status’ü activate edilebilir bir kayıtta Actions → Activate (confirm) → aynı hata; dataTable.ajax.reload() de .then içinde kaldığı için tablo yenilenmeyebilir.
    • Satıra girip Activate butonu → Detail.js aynı toastr.success.
  4. Permission yoksa aksiyon menüde görünmez: AbpIoAdmin.Organizations.Manage.SendWelcomeEmail / AbpIoAdmin.TrialLicenses.Manage.Update.

Www: abp.notify.* kullanıyor; bu hata yok. owl/timeago/jquery-form web UI’da bu nightly ile kırılmıyor.

Test: Admin wwwroot/libs/toastr olmamalı. Console typeof toastr === "undefined". Send Welcome Email tıkla → toastr is not defined.


Doğrulama

Select-String -Path "websites/abp.io/Directory.Packages.props" -Pattern "BlobStoring.Azure|preview202608|&#xD;"

dotnet build "websites/abp.io/src/Volo.AbpIo.Telemetry.Simulator" 2>&1 | Select-String "MSB3245"

Test-Path "websites/abp.io/src/Volo.AbpIo.Admin.Web/wwwroot/libs/toastr"

@gizemfirat

Copy link
Copy Markdown
Contributor Author

-> Findings h4, h5, and h6 are related to the vs-internal repository and are therefore not related to PR; relevant improvements will be made in the vs-internal repository.
-> In order to avoid creating a behavioral change within the current structure, no changes were made to PR. @yagmurcelk

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants