Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSB4018 - "ResolvePackageDependencies" task fails with "Invalid framework version '2.0/win'" #13942

Open
jbparker opened this issue Nov 19, 2024 · 1 comment
Assignees
Labels
Area:NuGetAudit Priority:1 High priority issues that must be resolved in the current sprint. Product:dotnet.exe RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug

Comments

@jbparker
Copy link

jbparker commented Nov 19, 2024

NuGet Product Used

MSBuild.exe

Product Version

MSBuild via VS 2022 17.12.0

Worked before?

Worked in VS 2022 17.11.5

Impact

It's more difficult to complete my work

Repro Steps & Context

The error is being emitted for PackageReference projects with the following attributes:

<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifiers>win</RuntimeIdentifiers>

Assumedly, this is where the 2.0/win comes from. There are many dozens of dependencies (package, product, etc), so determining how to singularly reproduce is exceedingly difficult.

Building and running the project itself does not seem to be impacted, but the error displaying is causing much confusion with developers that have upgraded VS on our team.

Adding <NuGetAuditMode>direct</NuGetAuditMode> to Directory.Build.props based on the auditing mode change made as part of .NET 9 removes the error from the Error List.

Verbose Logs

I can't get additional logs to show up in VS, but what shows in Error List is:

Severity: Error
Code: MSB4018
Description: The "ResolvePackageDependencies" task failed unexpectedly.
System.ArgumentException: Invalid framework version '2.0/win'.
   at NuGet.Frameworks.NuGetFramework.ParseFrameworkNameParts(IFrameworkNameProvider mappings, String[] parts, String& framework, Version& version, String& profile)
   at NuGet.Frameworks.NuGetFramework.ParseFrameworkName(String frameworkName, IFrameworkNameProvider mappings)
   at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.<GetPackageAndFileDefinitions>b__44_5(String tg)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.Contains[TSource](IEnumerable`1 source, TSource value, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
   at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.<GetPackageAndFileDefinitions>g__GetPackageDiagnosticLevel|44_0(LockFileLibrary package)
   at Microsoft.NET.Build.Tasks.ResolvePackageDependencies.GetPackageAndFileDefinitions()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
File: C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
Line: 196
@zivkan
Copy link
Member

zivkan commented Nov 19, 2024

The relevant code is in the dotnet/sdk repo, and is very likely related to the code I added to enable bubbling up warning overlay icons from the direct package to the dependencies node in VS's solution explorer:

@nkolev92 nkolev92 added Priority:1 High priority issues that must be resolved in the current sprint. RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:NuGetAudit Priority:1 High priority issues that must be resolved in the current sprint. Product:dotnet.exe RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug
Projects
None yet
Development

No branches or pull requests

4 participants