DEV Community

erkn
erkn

Posted on

[001] Create WPF Projects Like a PRO

TL;DR; Read only bold ones you fat.

I bet, you didn't know you can do like this.

[1] A purpose to open a WPF project

[2] JetBrains Rider (No Tonny, Visual Studio is bad for your health.)

[3] Open Rider ♥

[4] Click New Solution

[5] Select .Net Core (But sir I don't want dotnet core, I want my project in normal regular NetFramework X.Y bla bla bla...) Just select the fucking DotNet Core Desktop Application I will get there alright.

[6] Check Create .git and thank me now.

[7] Finally, hit the Create button (Do not forget to give a name to your $0.0F project.)

[8] Open the [projectname].csproj file. We have work to do.

[9] Change <TargetFramework> to <TargetFrameworks> for supporting more customer and earn more money and do more writing of course.

[10] Since you don't want to write with .Net Core remove netcoreapp3.1 and write net48

[11] For now, you should be able to Build and Run your project and see the worthless Window. Well done!

You might want to add multiple projects for your Business or Core or BLL for your garbage code.

[12] Guess next step. When you are creating new project you will always use .NetCore alrigt.

To understand the reasion you can create a regular project and compare *.csproj files.

[13] Go create a .NetCore ClassLibrary and repeat [8], [9] and [10]

[14] When you are create a class library on Rider, it does not automatically adds <UseWPF>true</UseWPF> like it adds on DesktopApplication so add it.

[15] Also same goes for Sdk="Microsoft.NET.Sdk.WindowsDesktop" too.

[16] As last step before write your own code create a class named AssemblyInfo.cs with filled with code:

using System.Windows;

[assembly: ThemeInfo(
    ResourceDictionaryLocation.None,
    ResourceDictionaryLocation.SourceAssembly 
)]

Now you are good to go.

If you do not do step [14] or [15] or [16] Rider cannot build and complain that you suck and do not deserve to use JetBrains Rider so you should go back to use Visual Studio like every regular boring developers do. (When Rider fixes this problem, this paragraph will destroy itself.).

Top comments (0)