Adding the first C# library reference fails when the project has no ItemGroup
維護者通常 1 天內回覆
@pcbeingused333 已經在處理了。
開始於 2026年11月22日。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 74/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 領域
- build-system, cli
研究方向
Start by reading LibraryManager._add_csharp_project_to_csproj and _add_csharp_package_to_csproj in lean/commands/library/add.py, then find the existing tests for C# library and NuGet insertion. Reproduce with a valid SDK style .csproj containing no ItemGroup and run the relevant tests. Done means both insertion paths create the first ItemGroup on the project root and the regression case passes.
由索引模型根據 Issue 內容生成。
描述
Problem
Adding a Lean C# library fails when the consuming .csproj has no ItemGroup. The library is nevertheless recorded in config.json, so repeating the command reports that it is already added while the .csproj still has no ProjectReference.
Reproduced on master at 3842533.
Reproduction
-
In an initialized Lean CLI directory, have C# projects
AppandLibrary/Lib. -
Give
App/App.csprojthis valid SDK-style content:<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net10.0</TargetFramework> </PropertyGroup> </Project> -
Run
lean library add App Library/Lib --no-local.
Observed: exit 1 with Argument '_parent' has incorrect type (expected lxml.etree._Element, got NoneType).
- Run the same command again.
Observed: exit 0 and Library Lib has already been added to the project App, but App.csproj still has no ProjectReference.
Cause and expected result
LibraryManager._add_csharp_project_to_csproj tries to create the first ItemGroup beneath csproj_tree.find(".//Project"). The parsed tree is already the Project element, so that descendant lookup returns None. _add_csharp_package_to_csproj in lean/commands/library/add.py contains the same insertion pattern.
Adding the first library reference should create the necessary ItemGroup on the project root and succeed for a valid project without one. Add regression coverage for this minimal .csproj case. Suggestion: reuse the correct root-insertion handling for both C# library-reference and NuGet-package insertion.
Impact is limited to projects without an existing ItemGroup; retaining an empty <ItemGroup /> before the first add avoids the crash.
- 主要語言
- Python
- 星號
- 335
- 分支
- 172
- 平均合併
- 6 小時 54 分鐘
- 30 天內合併 PR
- 37
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
QuantConnect/lean-cli 的其他 Issue
-
priority:P2
難度 2/5 1-3 小時 新手友好度 75/100
QuantConnect/lean-cli#792 ·
維護者通常 1 天內回覆
-
priority:P2
難度 2/5 1-3 小時 新手友好度 74/100
QuantConnect/lean-cli#786 ·
維護者通常 1 天內回覆
-
priority:P2
難度 2/5 1-3 小時 新手友好度 72/100
QuantConnect/lean-cli#785 ·
維護者通常 1 天內回覆
-
A partially written live command result aborts polling with JSONDecodeError可能已有人在做 @pcbeingused333 於 3 天前認領。 未關閉priority:P2
難度 2/5 1-3 小時 新手友好度 72/100
QuantConnect/lean-cli#784 ·
維護者通常 1 天內回覆
-
Container lookup failures during result polling are masked by UnboundLocalError可能已有人在做 @pcbeingused333 於 5 天前認領。 未關閉priority:P2
難度 2/5 1-3 小時 新手友好度 80/100
QuantConnect/lean-cli#783 ·
維護者通常 1 天內回覆
查看 QuantConnect/lean-cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
pimutils/vdirsyncer#1242 ·
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
open-webui/open-webui#35360 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)未關閉
難度 1/5 1 小時以內 新手友好度 68/100
-
bug
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆