3

我在 mac 上使用带有最新 .Net Core SDK 的 Visual Studio mac。在 Windows 上的 Visual Studio 2017 RC 中,一切正常,但是当我尝试使用 Visual Studio Mac 在 Mac 上恢复 nuget 包时,它会抛出错误。

包 Microsoft.Composition 1.0.27 与 netcoreapp1.1 (.NETCoreApp,Version=v1.1) 不兼容。包 Microsoft.Composition 1.0.27 支持:portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259) 一个或多个包与 .NETCoreApp,Version=v1.1 不兼容。

这是我的 *.csproj 文件

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

    <PropertyGroup>
        <Description>Some</Description>
        <Copyright>Some</Copyright>
        <AssemblyTitle>Some</AssemblyTitle>
        <TargetFramework>netcoreapp1.1</TargetFramework>
        <PreserveCompilationContext>true</PreserveCompilationContext>
        <AssemblyName>SharpCommerce</AssemblyName>
        <OutputType>Exe</OutputType>
        <PackageId>Some</PackageId>
        <UserSecretsId>aspnet-SharpCommerce-ecd1a4f7-1de0-468a-8065-ab902c7aae9b</UserSecretsId>
        <RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
        <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8;portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
        <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
        <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
        <GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
        <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
        <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
        <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
        <PreBuildEvent></PreBuildEvent>
    </PropertyGroup>

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

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.0">
  <PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0-msbuild3-final">
  <PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="1.1.0-preview4-final" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final">
  <PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="1.1.1" />
    <PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
    <PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="1.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.0" />
    <PackageReference Include="System.Reflection" Version="4.3.0" />
    <PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="1.3.2" />
</ItemGroup>

<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
    <Exec Command="bower install" />
    <Exec Command="dotnet bundle" />
</Target>


<ItemGroup>
    <ProjectReference Include="..\..\Some.Core.Contracts\Some.Core.Contracts.csproj" />
    <ProjectReference Include="..\..\Some.Core\Some.Core.csproj" />
</ItemGroup>

</Project>
4

3 回答 3

4

如果这个包是一个真正的 PCL(不使用 bait&switch),你应该可以使用 target fallback 来引用它。尝试添加

    <属性组>
        <PackageTargetFallback>dnxcore50;portable-net45+win8+wp8+wpa81</PackageTargetFallback>
    </属性组>

到你的项目。无法保证它不会在运行时崩溃。

于 2017-02-28T17:29:04.557 回答
0

Package Microsoft.Composition 1.0.27仅支持 .NET Framework 4.5、Windows 8、Windows Phone 8.1、Windows Phone Silverlight 8、可移植类库(PCL Profile 259),因此它与 Mac 上的 .Net Core 不兼容

有关包的 Nuget 信息 https://www.nuget.org/packages/Microsoft.Composition/1.0.27

于 2017-02-28T13:05:49.083 回答
0

来自支持的回答:

感谢您报告此事。预览版 4 中的 Visual Studio for Mac 忽略 PackageTargetFallback 信息。因此 project.assets.json 文件没有任何导入,这会阻止 NuGet 在应允许时安装 NuGet 包。这个错误应该在下一个版本中修复。

于 2017-03-10T15:24:48.070 回答