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

若如初见. 提交于 2021-01-27 19:37:55

问题


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:


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>


来源:https://stackoverflow.com/questions/44907819/microsoft-aspnetcore-hosting-abstractions-manifest-definition-does-not-match-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!