Reuse an XAF Shared Module between .NET Framework and .NET Applications
- 2 minutes to read
Original State and Migration Goals
Your migration goals or destination state are as follows:
Convert existing .NET Framework WinForms projects to .NET.
Add an ASP.NET Core Blazor Server and/or Backend Web API Service to an existing solution, and reuse your shared module (SolutionName.Module) and other projects with common data model, business logic, reports, Controllers and Actions, as well as platform-agnostic Application Model settings.
Keep your existing .NET Framework ASP.NET WebForms projects up and running, while you gradually migrate their users to XAF Blazor UI or non-XAF UI clients on .NET (JavaScript with DevExtreme or .NET MAUI, and so on). All apps work side by side and use the same database and shared modules.
Target Multiple .NET Platforms in a Single XAF Shared Module Project
Use Cross-platform targeting to reference a module in multiple applications or libraries for different target frameworks. This technique helps you avoid two .CSPROJ files for different Target Frameworks. A single .CSPROJ file defines the TargetFrameworks element and required dependencies for each target condition: <TargetFrameworks>net8.0;net48</TargetFrameworks>
We recommend this multi-targeting solution for both typical situations, where your shared XAF Module or Class Library project (SolutionName.Module) currently targets .NET Framework (<TargetFramework>net48;/TargetFramework>
) or .NET Standard 2.0 (<TargetFramework>netstandard2.0;/TargetFramework>
).
Example
If you used .NET Standard 2.0 to share code between .NET Framework and all other .NET implementations, here is a simple change that you will need to make to your cross-platform library (.CSPROJ) that supported .NET Standard in v23.1 (or earlier versions), when you upgrade its DevExpress dependencies to v23.2+.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- BEFORE (v23.1 and older)-->
<!-- <TargetFramework>netstandard2.0;/TargetFramework> -->
<!-- AFTER (v23.2 and newer) -->
<!-- Your shared Class Library will output net8.0 and net48 assemblies -->
<TargetFrameworks>net8.0;net48</TargetFrameworks>
</PropertyGroup>
</Project>
Also attached are complete sample projects for your reference. For more information, review this Breaking Change notice.