TwoSeven
TwoSeven

Reputation: 33

.Net Maui - how to create a class library?

I am just trying to migrate an old Xamarin app to .Net Maui in VS2022 (17.1.6). I have created the base application, however I have an old class library (dll) that contains common code that is used by more than one app.

Can anyone tell me what project type I need to use to create what in old .net standard terms would be a shared class library (dll).

I've read through the online documentation (as far as I can find it) and the focus is on individual apps and does not seem to mention much about shared components (non-ui).

I have seen references to a template called a .Net Maui Class library, but nothing tangible that I can use.

In Visual Studio I can see there are individual libraries for each platform (IOS, Android, Windows) but I am not terribly keen on writing the same code multiple times for different platforms.

There is a class library project which seems like it may work, but it says MacOS rather than IOS in the description.

Regards

Upvotes: 1

Views: 5477

Answers (2)

Rikudou En Sof
Rikudou En Sof

Reputation: 758

You can update your visual studio and get the Maui class library.

When I created a standard class library compatible with UWP, I however discovered that the Maui app can accept a .net core 6 class library.

With this, I can make the .net 6 class library reference (depend on) the .net Framework 2.0 class library and the code is properly referenced.

The problem becomes what can I do with a completely empty class Library? I wonder if I can squeeze in remote storage functions there? hmmm

Upvotes: 1

TwoSeven
TwoSeven

Reputation: 33

Thanks for the reply.

I updated to VS2022 17.2.0 Preview 5, and refreshed the Maui stuff from the VS Installer and I now have the Maui Class Library templates which does what I needed.

Upvotes: 1

Related Questions