简体   繁体   中英

.NET Core Solution design having issues with reference to old version libraries

I am in process of designing a basic application, where I would need to utilize my existing .Net libraries which I have written using Framework 4.5

I am trying to design following structure:

-CODE
  -Business.csproj
     - TargetFramework - netstandard1.6          
     - ProjectReference - domain.csproj built on .NET 45 framework.
  - WebApi.csproj
     -TargetFramework - netcoreapp1.1    
     - ProjectReference - Business.csproj 
-TEST
  - Business.Tests.csproj
     - TargetFramework - netstandard1.1          
     - ProjectReference - domain.csproj built on .NET 45 framework.  
     - ProjectReference - Business.csproj built on netstandard1.6 framework. 
  - WebAPI.Tests.csproj
     -TargetFramework - netcoreapp1.1    
     - ProjectReference - Business.csproj 
     - ProjectReference - WebApi.csproj 

Understanding:

  1. Business.csproj is targeting framework netstandard1.6 , as both .NET Framework (4.5.x) & .NET Core implements netstandard1.6
  2. WebApi.csproj is targeting framework netcoreapp1.1 as it is need for ASP.NET Core features & referencing project Business.csproj built on netstandard1.6

Now when try to restore packages - I am getting following errors:

  1. One or more packages are incompatible with .NETCoreApp,Version=v1.1.

  2. Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
    Error One or more packages are incompatible with .NETCoreApp,Version=v1.1.

If you are using project.json then you need to add an imports section to the project.json:

"frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      },
      "imports": "portable-net45+win8+wp8+wpa81"
    }
  }

If you're using .csproj then you need to modify the .csproj file like this:

<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM