XPO - How to Share Class Libraries with the DevExpress Data or XPO Dependencies for Different Target Frameworks

XPO Team Blog
08 November 2019

UPDATED on March 13th 2020:

The former core DevExpress.Data and DevExpress.Xpo assemblies for .NET Core 3 (WinForms & WPF) and .NET Framework apps have been changed in v20.1. Their functionality now resides in the following assemblies:

  • DevExpress.Data and DevExpress.Xpo for .NET Standard;
  • DevExpress.Data and DevExpress.Xpo for .NET Framework;
  • DevExpress.Data.Desktop for .NET Core 3 (WinForms & WPF);
  • DevExpress.Data.Desktop for .NET Framework.

These changes are done for easier maintenance, clearer dependencies, and future code extension of .NET Core apps and the corresponding NuGet packages. This also helps greatly simplify common development tasks like sharing Class Libraries with the DevExpress.Data or DevExpress.Xpo dependencies for different Target Frameworks. For more information, see The DevExpress.Data, DevExpress.Xpo, and other cross-platform assemblies for .NET Core 3 (WinForms & WPF), .NET Standard, and.NET Framework apps have been split or removed.

---------------------------------------

Early .NET Core 3.0 adopters (those targeting WinForms and WPF) might recall that sharing common libraries with the DevExpress.Data or DevExpress.Xpo assemblies is more difficult for the "netcoreapp3.0" and "netstandard2.0" projects.

The good news is that we found a simpler solution - Cross-platform targeting or Multi-Targeting. This approach will help you avoid two CSPROJ files for different Target Frameworks - less code duplication and maintenance costs for your solution. To make it work, the CSPOJ file defines TargetFrameworks element and required dependencies for each target conditions. You can download a working sample from this Support Center ticket (T808990). 

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;netcoreapp3.0</TargetFrameworks>
    <Description>Sample project that targets multiple TFMs</Description>
  </PropertyGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <PackageReference Include="DevExpress.Xpo" Version="19.2.3" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
    <PackageReference Include="DevExpress.WindowsDesktop.Xaf" Version="19.2.3-ctp" />
  </ItemGroup>
</Project>

The sample has the following structure and dependencies:

For more information on .NET Core 3.0 and .NET Standard 2.0 support in XPO, see this documentation topic.

Your Feedback Matters

Are you developing cross-platform libraries like this? If so, please share your thoughts and tell us other about the challenges you’ve encountered.

Are you experimenting with .NET Core 3? We’d love to know more about your experiences and whether you expect to port an existing WinForms and/or WPF app?

Showcase Your Apps on DevExpress.com

Highlight your business app and share your development experiences with the DevExpress community. To include your app in our upcoming App Showcase, please forward an application screenshot to clientservices@devexpress.com and tell us which DevExpress products you currently use within your organization.
2 comment(s)
Cyril Leuba
Cyril Leuba

I use this approach when I need to publish a library as a NuGet package.

This allows users of this library on different platform to use it smoothly as different dependencies may be specified regarding the platform (as it is already done for the XPO NuGet package).

8 November 2019
Dennis (DevExpress)
Dennis (DevExpress)
Thank you for sharing, Cyril!
8 November 2019

Please login or register to post comments.