Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Scenario
The project 'MyProject' is attempting to restore duplicate frameworks, which are supported only in the default dependency resolver when the .NET SDK is version 10.0.300 or newer. Upgrade your .NET SDK or remove RestoreUseLegacyDependencyResolver to use this feature.
Issue
Your project file has multiple TargetFrameworks entries that resolve to the same NuGet framework.
This scenario is known as framework aliasing, where different TargetFramework properties map to the same underlying framework.
For example, a project file like the following defines two target frameworks that both resolve to the same net9.0 NuGet framework:
<PropertyGroup>
<TargetFrameworks>net9.0-custom1;net9.0-custom2</TargetFrameworks>
</PropertyGroup>
Framework aliasing is supported only in the default dependency resolver, which requires .NET SDK 10.0.300 or later (SdkAnalysisLevel of 10.0.300 or later).
When the legacy dependency resolver is active (either because the SDK version is older or because RestoreUseLegacyDependencyResolver is set), the assets file format doesn't support duplicate frameworks, and NuGet raises this error.
Solution
Use one of the following approaches to resolve this error:
- Upgrade to .NET SDK 10.0.300 or later, which uses the default dependency resolver that supports framework aliasing.
- Remove the
RestoreUseLegacyDependencyResolverproperty from your project file orDirectory.Build.props, if it's set. This allows NuGet to use the default dependency resolver. - Remove duplicate framework entries from your
TargetFrameworksproperty so that each target framework resolves to a unique NuGet framework.