vscode-npm-gui
vscode-npm-gui copied to clipboard
No load and "More than one <ItemGroup> find" error.
Hi,
Just coming back to using this extension after some time, but the GUI hangs on load and I get the following error within a few moments of loading it:

what does this mean exactly? is there a more comprehensive log I can view?
thanks, jasen
have the same issue, in the code
if (newElm && newElm.length > 1) { throw "More than one <ItemGroup> find." }
is it possible to tell the file name or line details for quick locate?
Thanks
please can you share the csproj file?
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup> <<<<< this package only works with one itemgroup that related to the packages - Merge them together. >>>>>>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
</Project>
@aliasadidev in my case, I didn't find any duplicated PackageReference in each .csproj file, when I switch to Visual Studio, no issue to upgrade the pachages. in code, it gives that exception.
@jasonliao-cb, hi. Here is my case:
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="DotNetCore.CAP" Version="6.2.1" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="6.2.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="DotNetCore.CAP" Version="7.1.2" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="7.1.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="DotNetCore.CAP" Version="7.1.2" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="7.1.2" />
</ItemGroup>
Furthermore, from the Microsoft docs it's clear that multiple ItemGroups are valid (e.g. when conditions are used) and are normally created even by MS Visual Studio(s) itself.
In a simple project file, you normally use a single ItemGroup element, but you can also use multiple ItemGroup elements. When multiple ItemGroup elements are used, items are combined into a single ItemGroup. For example, some items might be included by a separate ItemGroup element that's defined in an imported file. ItemGroups can have conditions applied by using the Condition attribute. In that case, the items are only added to the item list if the condition is satisfied. https://learn.microsoft.com/en-us/visualstudio/msbuild/itemgroup-element-msbuild?view=vs-2022