Microsoft.AspNetCore.Hosting.Abstractions manifest definition does not match the assembly reference

.net-core entity-framework-core

Question

When I run the Entitfy framework core command add-migration MyMigrationName in a class library I get the following error

Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Funny thing there is no reference in my application to Abstractions.

Here is my csproj

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

    <PropertyGroup Label="Globals">
      <SccProjectName>SAK</SccProjectName>
      <SccProvider>SAK</SccProvider>
      <SccAuxPath>SAK</SccAuxPath>
      <SccLocalPath>SAK</SccLocalPath>
    </PropertyGroup>

    <PropertyGroup>
      <TargetFramework>net452</TargetFramework>
      <AssemblyName>MyProjectName</AssemblyName>
      <OutputType>Library</OutputType>
      <PackageId>MyProjectName</PackageId>
      <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
      <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
      <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
      <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
      <RootNamespace>MyProjectName</RootNamespace>
    </PropertyGroup>
    <ItemGroup>
      <None Update="appsettings.json">
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </None>
    </ItemGroup>
    <ItemGroup>
      <PackageReference Include="DocumentFormat.OpenXml" Version="2.5.0" />
      <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
      <PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
      <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
      <PackageReference Include="System.Collections" Version="4.3.0" />
      <PackageReference Include="System.Linq" Version="4.3.0" />
      <PackageReference Include="System.Runtime" Version="4.3.0" />
      <PackageReference Include="System.Threading" Version="4.3.0" />
    </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
  </ItemGroup>
</Project>
1
2
7/4/2017 2:22:22 PM

Accepted Answer

In order to get NuGet to add the appropriate binding redirects to class library projects, you need to add the following to your *.csproj file.

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
4
7/5/2017 3:23:58 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow