Skip to content

Commit

Permalink
docs: Add guide to Install Extensions in existing app
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Jun 14, 2024
1 parent 75f6fd7 commit c90d92d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
39 changes: 36 additions & 3 deletions doc/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
uid: Uno.Extensions.HowToGettingStarted
---
# How-To: Creating an application with Uno.Extensions
# How-To: Getting Started

This tutorial will walk you through how to create an Uno application with Uno.Extensions using the Wizard and CLI.
This tutorial will walk you through how to create an Uno application with Uno.Extensions using the Wizard and CLI and how to install Extensions to an existing Uno application.

> [!NOTE]
> Make sure to setup your environment first by [following our instructions](xref:Uno.GetStarted.vs2022).
## Step-by-steps
## Creating a new application

### 1. Creating the app

Expand Down Expand Up @@ -78,3 +78,36 @@ The generated solution will contain *MyProjectName* for application logic, inclu
![A screenshot of the generated targets](./Learn/images/GeneratedTargets-min.png)
* Click the "play" button, or press F5 to start debugging. The project will be compiled and deployed based on the target platform. For more detailed instructions specific to each platform, refer to the [Debug the App](xref:Uno.GettingStarted.CreateAnApp.VS2022#debug-the-app) documentation.
## Installing Extensions in an existing project
To get started with Extensions in your project, follow these steps:
### Step 1: Add Hosting to Your Project
Hosting is the foundation for using Extensions. Begin by adding Hosting to your project. Refer to the detailed instructions in the [Hosting Setup Documentation](xref:Uno.Extensions.Hosting.HowToHostingSetup).
### Step 2: Configure the OnLaunched Method
After setting up Hosting, adjust the `OnLaunched` method in `App.xaml.cs` to initialize the Extensions features. Ensure you have added the necessary [Uno Platform Features](xref:Uno.Features.Uno.Sdk#uno-platform-features).
Update the `Configure` method as shown below:
```csharp
var builder = this.CreateBuilder(args)
.Configure(host => host
// Configure the host builder
.UseConfiguration(...)
.UseLocalization()
.UseSerialization(...)
.UseHttp(...)
);
```

### Step 3: Use the Builder to Create the Main Window

Finally, instead of directly creating an instance of a `Window` using `MainWindow = new Window()`, use the `builder` to set up the main window:

```csharp
MainWindow = builder.Window;
```
8 changes: 6 additions & 2 deletions doc/Learn/Hosting/HostingOverview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ uid: Uno.Extensions.Hosting.Overview
---
# Hosting

`Uno.Extensions.Hosting` provides an implementation of the abstraction for building applications which support initialization of dependencies, establishing different environment types, and the full breadth of extensible features offered by Uno.Extensions.
`Hosting` provides an implementation of the abstraction for building applications which support initialization of dependencies, establishing different environment types, and the full breadth of extensible features offered by Uno.Extensions.

Hosting is delivered as a NuGet package [Uno.Extensions.Hosting.WinUI](https://www.nuget.org/packages/Uno.Extensions.Hosting.WinUI).
Hosting is provided as an Uno Feature. To enable `Hosting` support in your application, add `Hosting` to the `<UnoFeatures>` property in the Class Library (.csproj) file. For more information about `UnoFeatures` refer to our [Using the Uno.Sdk](xref:Uno.Features.Uno.Sdk) docs.

> [!IMPORTANT]
> This walkthrough assumes you created your app using the Single Project template. If you used a different template, please refer to our [Migrating Projects to Single Project](xref:Uno.Development.MigratingToSingleProject) documentation.
## Building a Hosted Application

Expand Down Expand Up @@ -78,6 +81,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
});

Host = appBuilder.Build();
}
...
```

Expand Down
13 changes: 11 additions & 2 deletions doc/Learn/Hosting/HowTo-HostingSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uid: Uno.Extensions.Hosting.HowToHostingSetup
---
# How-To: Get Started with Hosting

`Uno.Extensions.Hosting` can be used to register services that will be accessible throughout the application via dependency injection (DI). This tutorial will walk you through the critical steps needed to leverage hosting in your application.
`Hosting` can be used to register services that will be accessible throughout the application via dependency injection (DI). This tutorial will walk you through the critical steps needed to leverage hosting in your application.

> [!WARNING]
> The steps outlined here are unnecessary if you used the new project wizard template to create your solution. Otherwise, it is recommended that you follow the [Creating an application with Uno.Extensions article](xref:Uno.Extensions.HowToGettingStarted) for creating an application from the template.
Expand All @@ -12,7 +12,16 @@ uid: Uno.Extensions.Hosting.HowToHostingSetup

### 1. Installation

* Install the [Uno.Extensions.Hosting.WinUI](https://www.nuget.org/packages/Uno.Extensions.Hosting.WinUI) package from NuGet.
* Add `Hosting` to the `<UnoFeatures>` property in the Class Library (.csproj) file. If you already have `Extensions` in `<UnoFeatures>`, then `Hosting` is already installed, as its dependencies are included with the `Extensions` feature.

```diff
<UnoFeatures>
Material;
+ Hosting;
Toolkit;
MVUX;
</UnoFeatures>
```

### 2. Create and Configure IApplicationBuilder

Expand Down

0 comments on commit c90d92d

Please sign in to comment.