Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't upgrade or downgrade NuGet package

I have a ASP.NET Core website, and it relies on 2 class libraries.

They all reference Microsoft.NETCore but the versions have got mixed up somehow and has lead me to receive warnings:

Detected package downgrade: Microsoft.NETCore.App from 1.1.0 to 1.0.3

NuGet won't let me change the version of Microsoft.NetCore.App:

Cant update package

If I try to upgrade or downgrade, I get the error

Following versions are unavailable due to additional constraints in the project or packages.config

How do I solve this error?

My csproj file:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>AutomotiveWebPortalCore</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>AutomotiveWebPortalCore</PackageId>
    <UserSecretsId>aspnet-AutomotiveWebPortalCore-20170223120414</UserSecretsId>
    <RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
    <PackageTargetFallback>$(PackageTargetFallback);dotnet</PackageTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <Content Update="wwwroot\**\*;Views\**\*;Areas\**\Views;appsettings.json;web.config">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="5.2.0" />
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="1.2.0" />
    <PackageReference Include="DevExtreme.AspNet.Core" Version="16.2.4" />
    <PackageReference Include="DevExtreme.AspNet.Data" Version="1.2.4" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.0.1" />
    <PackageReference Include="bootstrap" Version="3.3.7" />
    <PackageReference Include="HubSpot.Tether" Version="1.1.1" />
  </ItemGroup>

  <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
  </Target>

  <ItemGroup>
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\AutomotiveDAL\AutomotiveDAL.csproj" />
    <ProjectReference Include="..\AutomotiveDTO\AutomotiveDTO.csproj" />
  </ItemGroup>

</Project>

Edit:

Here are the references for my class libraries:

Data Access Layer:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AutoMapper" Version="5.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-msbuild3-final" />
  </ItemGroup>

</Project>

Data Transfer Objects:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

</Project>
like image 917
Smithy Avatar asked Mar 06 '17 14:03

Smithy


1 Answers

The "Following versions are unavailable due to additional constraints" message seems to occur even in a brand new, empty ASP.NET Core project. I think it's either a bug or a feature of the NuGet GUI. (I'm using the final release version of Visual Studio 2017)

You can work around it by directly editing the .csproj file: right-click on the project in the Solution Explorer and select Edit (projectname).csproj.

You can bump up the version of Microsoft.NETCore.App (and the target framework) in the first PropertyGroup:

<PropertyGroup>
  <TargetFramework>netcoreapp1.1</TargetFramework>

  <!-- snip -->

  <RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>

  <!-- snip -->
</PropertyGroup>

Then, close the file and rebuild the project. I tested this with all the (public) dependencies you mentioned in your question and didn't see any package version conflicts.

like image 166
Nate Barbettini Avatar answered Oct 11 '22 13:10

Nate Barbettini