aliasadidev / vscode-npm-gui

vscode nuget package manager gui https://marketplace.visualstudio.com/items?itemName=aliasadidev.nugetpackagemanagergui
MIT License
46 stars 17 forks source link

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

Open jasenf opened 2 years ago

jasenf commented 2 years ago

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

jasonliao-cb commented 2 years ago

have the same issue, in the code

if (newElm && newElm.length > 1) { throw "More than one find." }

is it possible to tell the file name or line details for quick locate?

Thanks

aliasadidev commented 2 years ago

please can you share the csproj file?

aliasadidev commented 2 years ago
<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>
jasonliao-cb commented 2 years ago

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

merallisa commented 9 months ago

@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>
lcapka commented 7 months ago

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