Richard77
Richard77

Reputation: 21651

How to restore nuget packages when those packages' version are superior to the runtime's version?

I've cloned this solution from Azure DevOps. And according to my coworker, it's working fine in the cloud. When I open it using Visual studio 2019, it's not restoring all the nugget packages. The project is targeting netcore 2.1, when I change the target to netcore 2.2, it restores, build, and run.

Here's the project:

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

//...

<ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.1" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.1" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1" />
     <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
     <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.2.0-preview1-final" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.1.0-preview1-final" />
 </ItemGroup>

As one can see here, the target is 2.1 while many of the packages are 2.2.0 or above.

My question is to know whether there's another way of making this project on local besides targeting 2.2 framework?

Thanks for helping

Upvotes: 0

Views: 63

Answers (1)

Haktan Enes Bi&#231;er
Haktan Enes Bi&#231;er

Reputation: 692

Yes, you can open nuget manager and change package versions 2.1 or the way you want. Or you can change csproj like

ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
 </ItemGroup>

I think this is to risky because some method contents, names, parameters etc.. may have changed or new features may be included in version 2.2 of packages and they don't work for 2.1 versions.

Upvotes: 1

Related Questions