NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

[Bug]: warning NU1701: Package 'Microsoft.Azure.KeyVault.Core 1.0.0' #11778

Closed taoofstefan closed 2 years ago

taoofstefan commented 2 years ago

NuGet Product Used

Other/NA

Product Version

bot framework composer v2.1.2

Worked before?

No response

Impact

I'm unable to use this version

Repro Steps & Context

I use the Microsoft Bot Framework to create a bot. It worked fine until I installed the following package:

Microsoft.Bot.Components.AdaptiveCards

Afterwards I got the following error:

warning NU1701: Package 'Microsoft.Azure.KeyVault.Core 1.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project. All projects are up-to-date for restore.

I am not directly using 'Microsoft.Azure.KeyVault.Core 1.0.0' at all and I am not sure how to resolve this. Can anyone guide me? I saw some answers but I honestly couldn't make them work. I didn't know where to change the settings. The error remains even after uninstalling AdaptiveCards.

Thanks in advance :)

Verbose Logs

No response

erdembayar commented 2 years ago

Thank you filing this issue.

I can repro your issue on my local and found 2 solutions, there could be better way of doing this.

Solution 1. Suppress warning in your csproj or Directory.packages.props file.

<PropertyGroup>
  <NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>

Solution 2. Reference latest version of Microsoft.Azure.KeyVault.Core directly.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <RootNamespace>_11778</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Bot.Components.AdaptiveCards" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.KeyVault.Core" Version="3.0.5" />
  </ItemGroup>

</Project>

image

erdembayar commented 2 years ago

@taoofstefan

Sorry my machine crashed in middle of writing, below is not complete yet, I'll finish today or tomorrow. Here is more detailed approach how to solve this issue. You can find out how this indirect/transitive dependency brought in with VS 2022 Solution explorer. 1st search for id and expand Project > Dependencies> Packages to view it, see below.

image

Here path is Microsoft.Bot.Components.AdaptiveCards (1.0.0)-> Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime(4.13.1) -> Microsoft.Bot.Builder.Azure(4.13.1) -> Microsoft.Azure.Storage.Blob(9.4.2)->Microsoft.Azure.Storage.Common(9.4.2)->Microsoft.Azure.KeyVault.Core(1.0.0)

Why it's failing? Main reason is bad authoring, if you look at bottom dependency https://www.nuget.org/packages/Microsoft.Azure.KeyVault.Core/1.0.0 >> Frameworks is only net40, but higher dependency https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/9.4.2 >> Frameworks are netstandard1.3,netstandard2.0, net452. But later ones not compatible with net40.

Usually try to upgrade packages from top to bottom order, because top ones are most likely have more updated downstream dependencies. Upgrading packages one by one didn't resolve problem until I install Microsoft.Azure.Storage.Blob v11.2.3 (of course Microsoft.Azure.KeyVault.Core v3.0.5 solves too).

taoofstefan commented 2 years ago

@erdembayar thank you very much for your time and the provided solutions =)

I got it up and running with the first 2 suggestions and will have a look at your latest one too.