Adding a C# library can silently restrict its reference to Debug builds

Aperta
#767 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pcbeingused333 ci sta già lavorando.

Dal 22/11/2026.

  • #770 di @pcbeingused333 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, python
Ambito
build-system, cli

Direzione di ricerca

Start in lean/commands/library/add.py and inspect _add_csharp_project_to_csproj and _add_csharp_package_to_csproj, which the issue identifies as sharing the conditional last-ItemGroup behavior. Trace their existing tests and add regression coverage for a project whose last or only ItemGroup is conditional. Done means both added references are available in Debug and Release builds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

priority:P2

Problem

Adding a C# library can silently make its reference available only in Debug builds. The reference is appended to the last ItemGroup, even when that group has a configuration condition. The command succeeds and records the library in config.json, but Release builds cannot use it.

The reference-writing helper has this behavior on master at 51a654f.

Reproduction

  1. In an initialized Lean CLI workspace, have a C# project App and C# library Library/Lib. A minimal App/App.csproj is:

    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>net10.0</TargetFramework>
      </PropertyGroup>
      <ItemGroup Condition="'$(Configuration)' == 'Debug'" />
    </Project>
    
  2. Define ExampleLibrary.UsefulType in the library and use that type in the application.

  3. Run lean library add App Library/Lib --no-local.

The command exits successfully but inserts this reference inside the Debug-only group:

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
  <ProjectReference Include="../Library/Lib/Lib.csproj" />
</ItemGroup>
  1. dotnet build App/App.csproj -c Debug succeeds; dotnet build App/App.csproj -c Release fails with CS0246 for ExampleLibrary.

Verified through the library command and actual Debug/Release builds, and independently with _add_csharp_project_to_csproj loaded from the base commit above. _add_csharp_package_to_csproj in lean/commands/library/add.py uses the same last-group selection; directly adding a package also puts its PackageReference into the conditional group.

Expected result

Adding a library or package without a configuration restriction should make the new reference available in every build configuration. Regression tests should cover a project whose last or only ItemGroup is conditional.

Suggestion: share the group-selection/insertion logic between project and package references, selecting or creating an unconditional group rather than inheriting an unrelated group's condition.

Impact is limited to customized project files with conditional groups. Moving the new reference to an unconditional group is a workaround.

Lingua principale
Python
Stelle
335
Fork
172
Merge medio
6h 54m
PR unite (30g)
37

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QuantConnect/lean-cli

Tutte le issue di QuantConnect/lean-cli

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.