Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Visual Studio 2022 - Second Edition

You're reading from  Hands-On Visual Studio 2022 - Second Edition

Product type Book
Published in Mar 2024
Publisher Packt
ISBN-13 9781835080443
Pages 336 pages
Edition 2nd Edition
Languages
Authors (2):
Hector Uriel Perez Rojas Hector Uriel Perez Rojas
Profile icon Hector Uriel Perez Rojas
Miguel Angel Teheran Garcia Miguel Angel Teheran Garcia
Profile icon Miguel Angel Teheran Garcia
View More author details

Table of Contents (19) Chapters

Preface 1. Part 1: Visual Studio Overview
2. Chapter 1: Getting Started with Visual Studio 2022 3. Chapter 2: Creating Projects and Templates 4. Chapter 3: Debugging and Profiling Your Apps 5. Part 2: Tools and Productivity
6. Chapter 4: Adding Code Snippets 7. Chapter 5: Coding Efficiently with AI and Code Views 8. Chapter 6: Using Tools for Frontend and Backend Development 9. Chapter 7: Styling and Cleanup Tools 10. Chapter 8: Publishing Projects 11. Part 3: GitHub Integration and Extensions
12. Chapter 9: Implementing Git Integration 13. Chapter 10: Sharing Code with Live Share 14. Chapter 11: Working with Extensions in Visual Studio 15. Chapter 12: Using Popular Extensions 16. Chapter 13: Learning Keyboard Shortcuts 17. Index 18. Other Books You May Enjoy

Publishing Projects

After finishing a proof of concept or a minimum viable product (MVP) (which means a demo or pilot project with the main functionalities implemented, as discussed in Chapter 6, Using Tools for Frontend and Backend Development), we need to deploy our changes to see how the project works in a real scenario and share the published project with our customers. VS has a set of tools to deploy our projects. We can choose an option to deploy the project in our local environment, but we can also use services in the cloud.

In this chapter, you will learn how to deploy your projects with just a few clicks and VS 2022. The tools described will help you to save time and reduce complexity when you need to deploy.

We will discuss and review the following topics, which are the options to publish projects with VS 2022:

  • Publishing web apps
  • Publishing .NET MAUI apps
  • Publishing desktop apps

Let’s dive in and learn all about publishing projects.

...

Technical requirements

To replicate the concepts in this chapter, the following workloads must be installed using the Visual Studio Installer, as shown in Chapter 1, Getting Started with Visual Studio 2022, section Installing VS 2022:

  • .NET MAUI Multi-platform App UI development
  • .NET desktop development
  • ASP.NET and web development.

For the Publishing in Microsoft Azure subsection, you will need to have an Azure account with credits to complete the deployment.

You can download the projects required for this chapter from the following link: https://github.com/PacktPublishing/Hands-On-Visual-Studio-2022-Second-Edition/tree/main/Chapter%208.

Publishing web apps

VS has several ways to access the Publish option to configure the deployment of a web project. To follow along with this section, you can open the Chapter8_Code_Web project, which you will find in the Technical requirements section, or create an ASP.NET Core project.

One of the most common ways of accessing this option is to right-click on the project that we want to publish in the Solution Explorer tab (see Figure 8.1):

Figure 8.1 – The "Publish…" option on the menu after right-clicking

Figure 8.1 – The "Publish…" option on the menu after right-clicking

You can also reach the Publish window through the menu by navigating to Build | Publish [Project name]. By default, the main project in the current solution is selected.

Whatever the chosen option, VS will display a modal window to give you the deployment types supported for the main project in the solution or the project selected, as illustrated in the following screenshot:

Figure 8.2 – Options to publish a project in VS

Figure 8.2 –...

Publishing .NET MAUI apps

.NET MAUI is Microsoft’s technology for the creation of multi-platform applications. VS 2022 gives us tools to deploy applications to the different app stores in a simple way, in addition to providing us with ways to test the installation on local computers.

In this section, I will show you how to deploy a .NET MAUI application on the Android platform as it is the most common platform for the deployment of mobile apps.

Publishing an Android app with .NET MAUI

Once you have finished creating your .NET MAUI application, you will probably want to show it to the world through an application store.

We are going to do a test with the project called Chapter8_Code_MAUI, the link for which can be found in the Technical requirements section. Once you have opened this project, the first step is to assign a Release profile to your project, as shown in Figure 8.15:

Figure 8.15 – Switching the project to Release mode

Figure 8.15 – Switching the project to Release mode

...

Publishing desktop apps

ClickOnce is the technology used in VS 2022 to create installers for your desktop applications in a simplified way. This technology allows developers to publish and update their applications from a server or a shared network location so that application users can download, update, and install the app with just a couple of clicks.

For this demonstration, I have created a Widows Presentation Foundation (WPF) application named Chapter8_Code_WPF replicating the game Tic Tac Toe, which you can find in the download link in the Technical requirements section.

Once you have opened the project, you can run it, review the source code, or debug it, whatever you want to do. Then, go to the Solution Explorer and right-click on the project name (in our case Chapter8_Code_WPF) then Publish…, which will open a publishing wizard.

Figure 8.22 – The "Publish…" option to start the ClickOnce wizard

Figure 8.22 – The "Publish…" option to start the ClickOnce wizard

In this wizard...

Summary

After reading this chapter, you have learned about different ways to publish .NET-based projects, for web, multi-platform, and desktop applications.

First, we reviewed some of the options available in VS 2022 for deploying web applications. After reading this chapter, you now know how to use the Folder option, deploy your web app in the filesystem, and then use a server to host an application. You also know how to deploy a project in the IIS server using VS. You learned how to deploy a project in Azure using the Azure App Service option in Windows and a publishing configuration using the .pubxml file.

Afterward, you observed the step-by-step process to generate an .aab file from a .NET MAUI project, which you could install on an Android mobile device or publish in the Google app store.

Finally, you saw how to perform a deployment using the ClickOnce tool, which greatly facilitates the generation of installers for desktop applications.

In Chapter 9, Implementing...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Hands-On Visual Studio 2022 - Second Edition
Published in: Mar 2024 Publisher: Packt ISBN-13: 9781835080443
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}