如何解决ASP.NET.Core 2包恢复相关的警告和错误

时间:2017-08-06 07:38:44

标签: asp.net authentication asp.net-core-2.0

每当我启动.NET CORE 2 Web App项目使用身份验证(即个人身份验证)时,我会收到以下警告:

  

Package' Microsoft.Composition 1.0.27'使用' .NETPortable,Version = v0.0,Profile = Profile259,.NETFramework,Version = v4.6.1'进行了恢复。而不是项目目标框架' .NETCoreApp,Version = v2.0'。此软件包可能与您的项目不完全兼容。

问题不止于此,我正在尝试安装Microsoft.AspNetCore.Authentication.Cookies,我收到以下错误:

  

包恢复失败。回滚项目的包更改

我尝试了以下操作,全部失败!

  1. 正在删除Nuget.Config
  2. 我添加了<PropertyGroup> <PackageTargetFallback>$(PackageTargetFallback);dotnet</PackageTargetFallback> </PropertyGroup>
  3. 通过dotnet restore
  4. 恢复套餐
  5. 清除Nuget缓存(来自工具&gt; NuGet&gt;程序包管理器设置)
  6. 如何解决此冲突?

    这是我的项目文件

    &#13;
    &#13;
    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>netcoreapp2.0</TargetFramework>
        <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
        <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
        <UserSecretsId></UserSecretsId>
      </PropertyGroup>
      <PropertyGroup>
        <PackageTargetFallback>$(PackageTargetFallback);dotnet</PackageTargetFallback>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview2-final" PrivateAssets="All" />
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0-preview2-final" PrivateAssets="All" />
      </ItemGroup>
    
      <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />
        <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0-preview2-final" />
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
      </ItemGroup>
    
    </Project>
    &#13;
    &#13;
    &#13;

    和我屏幕上的快照

1 个答案:

答案 0 :(得分:0)

通过添加.csproj并使用NuGet更新以下包来解决依赖性问题,

<PackageReference Include="Microsoft.Composition" Version="1.0.27" ExcludeAssets="All" />  
<PackageReference Include="System.Composition" Version="1.0.31" />

.csproj是

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
    <UserSecretsId>***********</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.Composition" Version="1.0.31" ExcludeAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0-preview2-final" />
    <PackageReference Include="System.Composition" Version="1.1.0-preview2-25405-01" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview2-final" PrivateAssets="All" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0-preview2-final" PrivateAssets="All" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0-preview2-final" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0-preview2-final" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
  </ItemGroup>

</Project>

RefRef2