Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
36
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 2 Building Our First application

\3.\ Create the application, giving the project a name: dotnet new maui --name WidgetBoard

\4.\ cd to the new folder, WidgetBoard:

cd WidgetBoard

\ 5.\ Pull in all dependencies for the application:

dotnet restore

You now have a .NET MAUI application. Let’s proceed to learning how to build and ultimately run it.

Building and Running Your First Application

Now that you have your project created, let’s go ahead and build and run it in order to get familiar with the tooling. The introduction of the single project approach for .NET MAUI applications may bend your way of thinking when it comes to building applications. In the past, a solution containing .NET projects would typically have a single start-up project, but these projects would have a single output. Now that a single project actually has multiple outputs, you need to learn how to configure that for your builds. In fact, this is done by clicking the down arrow, which can be seen in Figure 2-16.

38

Chapter 2 Building Our First application

Figure 2-16.  Build target selection dropdown in Visual Studio

You may also notice the dropdown in the above image that currently says WidgetBoard (net7.0-android). This allows you to show in the visible file what applies to that specific target, but it does not affect what you are currently compiling. Figure 2-17 shows this a little clearer.

\1.\ This is where you set the current target to compile for and run.

\2.\ This is highlighting in the code file what will compile for the target chosen in the dropdown. Notice here that you are compiling for Windows but showing what would compile for Android.

39

Chapter 2 Building Our First application

Figure 2-17 highlights items 1 and 2 from the above list to highlight what is compiled vs. what is targeted in Visual Studio.

Figure 2-17.  Showing the differences between what target is being compiled and what target is being shown in the current editor

40