Adding the first C# library reference fails when the project has no ItemGroup
Les mainteneurs répondent en général sous 1 jour
@pcbeingused333 y travaille déjà.
Depuis le 22/11/2026.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 74/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Domaine
- build-system, cli
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 335
- Forks
- 172
- Merge moyen
- 6 h 54 min
- PR mergées (30 j)
- 37
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de QuantConnect/lean-cli
-
priority:P2
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
QuantConnect/lean-cli#792 ·
Les mainteneurs répondent en général sous 1 jour
-
priority:P2
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
QuantConnect/lean-cli#786 ·
Les mainteneurs répondent en général sous 1 jour
-
priority:P2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
QuantConnect/lean-cli#785 ·
Les mainteneurs répondent en général sous 1 jour
-
A partially written live command result aborts polling with JSONDecodeErrorPeut-être pris @pcbeingused333 l’a pris il y a 3 jours. Ouvertepriority:P2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
QuantConnect/lean-cli#784 ·
Les mainteneurs répondent en général sous 1 jour
-
Container lookup failures during result polling are masked by UnboundLocalErrorPeut-être pris @pcbeingused333 l’a pris il y a 5 jours. Ouvertepriority:P2
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
QuantConnect/lean-cli#783 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de QuantConnect/lean-cli
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
pimutils/vdirsyncer#1242 ·
-
backlog
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
sagemathinc/sagebrush#2768 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
vllm-project/vllm-ascend#23791 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
briandconnelly/context-audit#33 ·
Les mainteneurs répondent en général sous 1 jour