.NET Core 3.1 WPF is ready. It works fabulously. The new SDK Style .cs project has brevity and does not generate GUIDS secretly, it intuitively 'knows' what to compile. As we migrate, and we should, many of us will want a Side-by-Side Migration Strategy.
Side-by-Side Strategy Means
- Your legacy framework project is still available and runs and deploys.
- The ported csproj will be located in the same folder as the legacy framework project.
- The XAML designer will work.
- Build all / Clean all for solution will work as expected.
- There is no Project Template that actually works to build such a project.
Templates in Visual Studio 2019
There is, by now, a terrifyingly large number of Templates these days in Visual Studio. Unfortunately, there are also missing templates; the missing Template is one that allows your app to be compiled in a Side By Side Strategy. That missing template is provided here: (gist) albeit in a somewhat manual form.
As opposed to going on Deep-dive about the new .NET Core project, let's compare two csprojects and get an app I wrote working in side-by-side mode. The project we will test out has an article written about it here.
Trying Out the Template (A 12 Step Program)
- Open un-ported sample WPF project here: https://github.com/BicycleMark/LatestSweeper/tree/AddCore_3_1.
- Verify Compile.
- Verify XAML Designer is displaying app at design time open mainwindow.xaml.
- Verify Run (Take time to learn how the app behaves).
- In solution EXP, Right click and unload the project [Sweeper].
- In Solution EXP, open the Solution Items node and view: [Sweeper.csproj] notice 306 lines.
- In Solution EXP, open the Solution Items and now and view [SweeperCore.csproj] notice 45 lines.
- In Solution EXP, Reload [Sweeper.csproj].
- In Solution EXP, Right Click on solution -> Add Existing project [SweeperCore.csproj].
- Build All.
- Verify the Designer is working.
- Run and verify the Core Project
I have provided a gist of the proposed migration template. I will be updating it as I learn more from other projects. I hope to hear from those of you trying side-by-side migations with this gist as your starting point.
Keep in mind that there are only three things that need to be modified in the gist template in the <!-- Commented part -->
- <!-- Customize Resource Statements For your Project Start-->
You may modify by hand in csproj or in IDE. If IDE, the first 2 are on project Properties->Application tag. The Resource Statements can be modified by changing the Build Action to "Resource" for each individual file. Alternatively, you can include a recursive file pattern that includes subfolders:
<Resource Include="Resources\**\*.png" />
<Resource Include="Resources\**\*.ico" />
What I Learned
- The csproject can be greatly simplified in .NET Core.
- .NET Core Rocks. .NET Core will not be another WinRT bridge to nowhere.
- The new project format has a learning curve, but it is worth the effort. It knew what folders had stuff to compile in them and did so without being spelled out.
- The new project and old project format seem to struggle at co-existing.
- Most of the length of the core project was aimed at making it co-exist with the old.
- It is beneficial to make them co-exist, the benefits include access to the designer and orderly migration from legacy to .NET Core.
- You can spend a lot of time reading documents, trying tools, getting confused and still not be ported.
- The new SDK Style project is awesome.
- Microsoft should address rapid porting and provide a migration template in Visual Studio.
- Try the .NET Core Template on your Framework projects there are use this gist.
- Give me feedback and problems from others using this template. Put in comments below.
- With feedback, build a Visual Studio plugin that performs the preceding manual steps.
I hope this helps you get ported ASAP! If it did, let me know. If it did not, let me know that as well. Please place your github url in the comments. Ready! Set! Port!
- 4th July, 2020: Initial publication
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.