For a while now I have been trying to create a framework for XAF (yes I know XAF is already a framework) but it was too difficult to handle the different version of XAF and upgrade the solution from version to version.

Luckily for me, DevExpress team decided to publish all their DLLs as nuget packages, you can learn more about that here. But there was still one problem for me, at that time they did not include the nugets for XAF, later that year (2018) they decided to publish the nugets for XAF, you can read about it here

Now I have all the pieces to create the project template for the modules of my framework, at least that is what I thought, there was still one more stone in my path and it was the csproj file. At this moment (version 18.2.x) XAF project templates are based on visual studio 2015 project format, so the way the projects handles nuget references is based on the old standard packages.config, another problem is that if you want to package your module as a nuget you have to use the old package.nuspec.

So let’s migrate our XAF module project to the new version of csproj, but first take a look to the old version of the file in the image below

 

Once you have a XAF solution open on visual studio these are the steps to do the migration

1) Right click on your module file and select “Unload Project”

2) Now that the project us unloaded it will appear unavailable in the solution explorer, so we can right click over it and select “edit”

4) Delete all the content of your csproj and replace it with this XML, you can also change the version of nuget files, in this case, I’m using 18.2.6


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <GenerateAssemblyInfo>true</GenerateAssemblyInfo>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="DevExpress.ExpressApp.Security.Xpo" Version="18.2.6" />
    <PackageReference Include="DevExpress.ExpressApp.Validation" Version="18.2.6" />
    <PackageReference Include="DevExpress.Persistent.BaseImpl" Version="18.2.6" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>
</Project>

5)Delete the file AssemblyInfo.cs from the properties folder

 

Congratulations you have successfully migrated your csproj file

Now some advantages and disadvantages of this new csproj format

Advantages
  1. Smaller project file easy to edit
  2. improved usage of nuget packages
  3. its easier to pack your module as a nuget
Disadvantages
  1. You can not use the Devexpress add item context menu because it will add references to local assemblies
  2. The module designer stop working so you have to do all your module configuration in code