Multi-targeting .net core 2.2 with .net 4.6.1

.net .net-core c# entity-framework-core oledbconnection

Accepted Answer

ZZZ_tmp
0
12/14/2019 4:05:47 PM

Popular Answer

For.NET Core, you only have package references available. If applicable, you should have an item group for each of the following:

  • assembly references for the.NET Framework (with a target framework)Condition )
  • references to Nuget packages that are necessary for both target frameworks
  • References to Nuget packages that are required solely for the.NET Framework (with a target framework)Condition )
  • References to Nuget packages that are required solely for.NET Core (with a target framework)Condition )

Additionally, System.Data.OleDb.OleDbConnection is 40-zzz-zzz. You must make reference to the Nuget package System.Data.OleDb.

Please try eliminating.Condition=" '$(TargetFramework)' == 'netcoreapp2.2'" using theItemGroup and include a reference to the System package. Data.OleDb.

Study my example below if you need to use any specific framework-specific references.


Here are some examples of the package references from one of my libraries that supports.NET Standard 2.0 and.NET 4.8:

  <ItemGroup Condition="'$(TargetFramework)'=='net48'">
    <Reference Include="System.Configuration" />
    <Reference Include="System.Data.Linq" />
    <Reference Include="System.ServiceModel" />
    <Reference Include="System.ServiceModel.Web" />
    <Reference Include="System.Web.Extensions" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
    <PackageReference Include="System.Diagnostics.EventLog" Version="4.6.0" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
    <PackageReference Include="NodaTime" Version="2.4.7" />
  </ItemGroup>

Take note of my references. Framework NET Framework assembliesnet48 using a single Nuget packagenetstandard2.0 for both targets, as well as 3 Nuget packages.



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