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

未關閉
#767 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@pcbeingused333 已經在處理了。

開始於 2026年11月22日。

  • #770 來自 @pcbeingused333 —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
74/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
csharp, python
領域
build-system, cli

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
335
分支
172
平均合併
6 小時 54 分鐘
30 天內合併 PR
37

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

QuantConnect/lean-cli 的其他 Issue

查看 QuantConnect/lean-cli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。