Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Exception converting project 'Sequence contains more than one element' #388

Closed
ejohnson-dotnet opened this issue Mar 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@ejohnson-dotnet
Copy link

Trying to convert any project I am getting the following exception:

System.InvalidOperationException
  HResult=0x80131509
  Message=Sequence contains more than one element
  Source=System.Linq
  StackTrace:
   at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at MSBuild.Conversion.SDK.TargetFrameworkHelper.FindHighestInstalledTargetFramework(Boolean usePreviewSDK) in 
C:\try-convert\src\MSBuild.Conversion.SDK\TargetFrameworkHelper.cs:line 60

Line 60 in TargetFrameworkHelper.cs is:

var templateNugetPackagePath = Directory.EnumerateFiles(templatePath, "microsoft.dotnet.common.projecttemplates.*.nupkg", SearchOption.TopDirectoryOnly).Single();

Debugging this, the variable templatePath = "C:\\Program Files\\dotnet\\templates\\5.0.4"
If I look in that folder I find these two matching files:
microsoft.dotnet.common.projecttemplates.5.0.5.0.4.nupkg
microsoft.dotnet.common.projecttemplates.5.0.5.0.200-preview.21109.7.nupkg

I have not installed any .NET Core preview releases or anything like that, only official released packages.

@cartermp
Copy link
Contributor

This tool doesn't install any templates, so you must have acquired that somewhere else. I will track this as a bug though, since we should probably be resilient to this. Happy to look at a PR as well.

@cartermp cartermp added the bug Something isn't working label Mar 26, 2021
ejohnson-dotnet pushed a commit to ejohnson-dotnet/try-convert that referenced this issue Mar 26, 2021
Fix for dotnet#388 when there are multiple project template files in the path.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants