vscode-npm-gui icon indicating copy to clipboard operation
vscode-npm-gui copied to clipboard

No load and "More than one <ItemGroup> find" error.

Open jasenf opened this issue 2 years ago • 6 comments

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:

image

what does this mean exactly? is there a more comprehensive log I can view?

thanks, jasen

jasenf avatar Jun 06 '22 13:06 jasenf

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

jasonliao-cb avatar Jun 10 '22 06:06 jasonliao-cb

please can you share the csproj file?

aliasadidev avatar Jun 12 '22 06:06 aliasadidev

<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 avatar Jun 12 '22 06:06 aliasadidev

@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 avatar Jun 13 '22 01:06 jasonliao-cb

@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>

merallisa avatar Sep 21 '23 09:09 merallisa

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

lcapka avatar Dec 07 '23 13:12 lcapka