try-convert icon indicating copy to clipboard operation
try-convert copied to clipboard

Error - Sequence contains more than one matching element

Open DanielHabenicht opened this issue 3 years ago • 0 comments

For the following .csproj:

<Project>
    <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
    <PropertyGroup Label="Globals">
        <SccProjectName>SAK</SccProjectName>
        <SccProvider>SAK</SccProvider>
        <SccAuxPath>SAK</SccAuxPath>
        <SccLocalPath>SAK</SccLocalPath>
        <Configurations>Debug;Release;Staging</Configurations>
        <!-- Also I had to manually add the Output Type for this Test Project -->
        <OutputType>Exe</OutputType>
    </PropertyGroup>

    <PropertyGroup>
        <TargetFramework>NET471</TargetFramework>
        <PlatformTarget>x64</PlatformTarget>
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
        <RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    </PropertyGroup>
</Project>

I am getting this error:

System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at MSBuild.Abstractions.MSBuildHelpers.GetOrCreateTopLevelPropertyGroupWithTFM(IProjectRootElement rootElement) in /_/src/MSBuild.Abstractions/MSBuildHelpers.cs:line 308
   at MSBuild.Conversion.Project.ProjectRootElementExtensionsForConversion.AddGenerateAssemblyInfoAsFalse(IProjectRootElement projectRootElement, ProjectStyle projectStyle) in /_/src/MSBuild.Conversion.Project/ProjectRootElementExtensionsForConversion.cs:line 526
   at MSBuild.Conversion.Project.Converter.ConvertProjectFile() in /_/src/MSBuild.Conversion.Project/Converter.cs:line 37
   at MSBuild.Conversion.Project.Converter.Convert(String outputPath) in /_/src/MSBuild.Conversion.Project/Converter.cs:line 31
   at MSBuild.Conversion.Program.Run(String project, String workspace, String msbuildPath, String tfm, Boolean forceWebConversion, Boolean preview, Boolean diffOnly, Boolean noBackup, Boolean keepCurrentTfms, Boolean update, Boolean mauiConversion) in /_/src/try-convert/Program.cs:line 159

I don't know if some of my coworkers made a mistake 5 years ago by introducing the <TargetFramework>NET471</TargetFramework> in the second <PropertyGroup> but it is resolved by moving it into the first.

DanielHabenicht avatar Oct 20 '21 10:10 DanielHabenicht