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

XPO Team Blog
08 November 2019

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">
    <Description>Sample project that targets multiple TFMs</Description>
  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <PackageReference Include="DevExpress.Xpo" Version="19.2.3" />
  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
    <PackageReference Include="DevExpress.WindowsDesktop.Xaf" Version="19.2.3-ctp" />

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?

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.