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
- Smaller project file easy to edit
- improved usage of nuget packages
- its easier to pack your module as a nuget
Disadvantages
- You can not use the Devexpress add item context menu because it will add references to local assemblies
- The module designer stop working so you have to do all your module configuration in code
Great post!
If you want the automated way, you can use https://github.com/hvanbakel/CsprojToVs2017/blob/master/README.md that does a lot of the plumbing for you!
Regards
Manuel
Thanks for the info Manuel, it’s funny my second name is Manuel, so as we said in Spanish we are Tocayo.
The main purpose of the post it’s actually understanding what is happening inside of the csproj because the next post is about multi-targeting and conditional compiling modules that target different versions of XAF
Hi Manuel!
Hehe in German it’s called ‘Namensvetter’!
It was just in case you didn’t know the tool exists!
That sounds very interesting, looking forward for the next post!
THis post did not work for me Joche. I am trying to upgrade from devexpress 19.2.6.0 to 20.1.3.0 and this short steps were not enougth … when I did all the steps for my .Module project , and i updated all the references in the 3 .csproj files, and I am getting an inner exception saying “The base class includes the field ‘ProgressControl’, but its type (DevExpress.ExpressApp.Web.Controls.ASPxProgressControl) is not compatible with the type of control (DevExpress.ExpressApp.Web.Controls.ASPxProgressControl).”
Can you check it out this?
Ya le cambie la referencia a la clase base del asemmbly DevExpress.ExpressApp.Web.Controls.ASPxProgressControl y ahora me dice que “error CS0433: The type ‘DevExpress.ExpressApp.Web.Controls.ASPxProgressControl’ exists in both assembly”. Esto me tiene mal
Si esta tratando de migrar el proyecto de la aplicacion web, ese no se puede miegrar ya que los proyectos aspnet tradicional no van a migrar a ese formato
Tambien puede probar esto https://github.com/hvanbakel/CsprojToVs2017/blob/master/README.md