Adding the first C# library reference fails when the project has no ItemGroup
Mantenedores costumam responder em até 1 dia
@pcbeingused333 já está trabalhando nisso.
Desde 22/11/2026.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 74/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Domínio
- build-system, cli
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 335
- Forks
- 172
- Merge médio
- 6h 54min
- PRs com merge (30d)
- 37
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de QuantConnect/lean-cli
-
priority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
QuantConnect/lean-cli#792 ·
Mantenedores costumam responder em até 1 dia
-
priority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
QuantConnect/lean-cli#786 ·
Mantenedores costumam responder em até 1 dia
-
priority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
QuantConnect/lean-cli#785 ·
Mantenedores costumam responder em até 1 dia
-
A partially written live command result aborts polling with JSONDecodeErrorTalvez já em andamento @pcbeingused333 assumiu há 3 dias. Abertapriority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
QuantConnect/lean-cli#784 ·
Mantenedores costumam responder em até 1 dia
-
Container lookup failures during result polling are masked by UnboundLocalErrorTalvez já em andamento @pcbeingused333 assumiu há 5 dias. Abertapriority:P2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
QuantConnect/lean-cli#783 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de QuantConnect/lean-cli
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
Mantenedores costumam responder em até 4 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
pimutils/vdirsyncer#1242 ·
-
backlog
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
sagemathinc/sagebrush#2768 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
vllm-project/vllm-ascend#23791 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
briandconnelly/context-audit#33 ·
Mantenedores costumam responder em até 1 dia