Skip to content

"Sequence contains no matching element" when using a bad TF #13772

Open
@dfederm

Description

@dfederm

NuGet Product Used

MSBuild.exe

Product Version

MSBuild version 17.9.8+b34f75857 for .NET Framework

Worked before?

No

Impact

It's more difficult to complete my work

Repro Steps & Context

Error:

...\Current\bin\NuGet.targets(169,5): error : Sequence contains no matching element [<repo>\dirs.proj]

This happened when accidentally using:

    <TargetFramework>net8.0;net472</TargetFramework>

This is clearly a user error, but the error message could be more helpful. At the very least it should point to the problematic project instead of the root project for the restore.

I can only get this specific error to repro under certain conditions which I'm not able to fully understand. eg it manifests this way when restoring from the root. When restoring the project directly I helpfully get:

NETSDK1046: The TargetFramework value 'net8.0;net472' is not valid. To multi-target, use the 'TargetFrameworks' property instead.

I would guess it maybe only manifests when a projects depends on the problematic project? Not super sure though.

Attaching a debugger shows that the exception is thrown here:
image

And the stack in case it's helpful:
image

I can provide more specific details (specific internal repo and commit) offline if desired.

Verbose Logs

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions