Adding a C# library can silently restrict its reference to Debug builds
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- build-system, cli
Research direction
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.
Written by the indexing model from the issue text.
Description
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
-
In an initialized Lean CLI workspace, have a C# project
Appand C# libraryLibrary/Lib. A minimalApp/App.csprojis:<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net10.0</TargetFramework> </PropertyGroup> <ItemGroup Condition="'$(Configuration)' == 'Debug'" /> </Project> -
Define
ExampleLibrary.UsefulTypein the library and use that type in the application. -
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>
dotnet build App/App.csproj -c Debugsucceeds;dotnet build App/App.csproj -c Releasefails withCS0246forExampleLibrary.
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.
- Dominant language
- Python
- Stars
- 335
- Forks
- 172
- Avg merge
- 6h 54m
- Merged PRs (30d)
- 37
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QuantConnect/lean-cli
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
QuantConnect/lean-cli#792 ·
Maintainers usually reply within 1 day
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantConnect/lean-cli#786 ·
Maintainers usually reply within 1 day
-
priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/lean-cli#785 ·
Maintainers usually reply within 1 day
-
A partially written live command result aborts polling with JSONDecodeErrorPossibly taken @pcbeingused333 claimed this 3 days ago. Openpriority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
QuantConnect/lean-cli#784 ·
Maintainers usually reply within 1 day
-
Container lookup failures during result polling are masked by UnboundLocalErrorPossibly taken @pcbeingused333 claimed this 5 days ago. Openpriority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
QuantConnect/lean-cli#783 ·
Maintainers usually reply within 1 day
All issues in QuantConnect/lean-cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pimutils/vdirsyncer#1242 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
open-webui/open-webui#35360 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Suggest link: Destiny Verify (MIT zero-dependency pre-commit security, citation & link hygiene CLI)Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day