From a6095066067207c715023eb818b4cb35eaec389a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Wed, 19 Jun 2024 13:51:17 -0400 Subject: [PATCH 1/2] docs: Adjust tfm restrictions for 5.2+ single project --- ...olution-building-single-targetframework.md | 76 +++++++++++++++++-- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/doc/articles/guides/solution-building-single-targetframework.md b/doc/articles/guides/solution-building-single-targetframework.md index af03ef8c80a0..403911623947 100644 --- a/doc/articles/guides/solution-building-single-targetframework.md +++ b/doc/articles/guides/solution-building-single-targetframework.md @@ -6,17 +6,71 @@ uid: Build.Solution.TargetFramework-override The Uno Platform template **prior to Uno Platform 5.2** provides a cross-targeted Class library that includes multiple target frameworks, and your application may contain your own cross-targeted projects as well. This document explains how to make your builds faster. > [!NOTE] -> For projects created with Uno Platform 5.2 or later, the Uno.Sdk takes care of building appropriate target frameworks for the selected debugger target. Optionally, you can follow [our migration guide](xref:Uno.Development.MigratingToSingleProject) to use the new project structure. +> For projects created with Uno Platform 5.2 or later, the Uno.Sdk takes care of building appropriate target frameworks for the selected debugger target when starting a debugging session. Optionally, you can follow [our migration guide](xref:Uno.Development.MigratingToSingleProject) to use the new project structure. If you want to always build one target framework you can follow the guide below. -## Cross-targeted library builds in Visual Studio +## Reduce the number of built TargetFrameworks (5.2 templates and later) -While building with the command line `dotnet build -f net7.0-ios` only builds the application's head and the class library for `net7.0-ios`, as of Visual Studio 17.8, class library builds are considering all target frameworks, [regardless of the project head's target framework](https://developercommunity.visualstudio.com/t/Building-a-cross-targeted-project-with-m/651372) being built. _(Please help the Uno Platform community by upvoting the issue!)_ +When using an Uno Platform 5.2 template or later, in the **Folder Explorer**, you can apply the following steps to build only a subset of target frameworks using a configuration file. -Considering that during development, it is common to work on a single platform at a given time, the two sections below contain a suggested set of changes to the Uno Platform solution that can be performed on the solution to restrict the active build platform, and therefore significantly speed up build times and make intellisense respond faster. +To do so: -Choose the section that covers your cases, whether you're using a solution built using Uno Platform 5.0 templates, or if it was created with an earlier version. +- Create a file named `solution-config.props.sample` next to your `.sln` file, with this content: + + ```xml + + + + + + + + + + + + + + + ``` + + Make sure to replace `net8.0` and `-windows10.0.19041.0` with the appropriate version from your `.csproj` project. + +- You can commit `solution-config.props.sample` to your source control. +- Next, make a copy of `solution-config.props.sample` to `solution-config.props`. This file is [automatically loaded](https://github.com/unoplatform/uno/blob/71f1d5ab067c0dcfad2f4cccd310e506cdeaf6bf/src/Uno.Sdk/targets/Uno.Import.SolutionConfig.props#L9) by the `Uno.Sdk`. +- If you're using git, add this `solution-config.props` to your `.gitignore`. + + > [!NOTE] + > This avoids altering the target frameworks or your own CI, as well as other clones made by other developers. -## Improve performance using the Uno Platform templates +- Follow the directives from the file, uncommenting one of the `OverrideTargetFramework` to your choosing. +- In the project head, as well as any other libraries using the `Sdk="Uno.Sdk"`, add the following block immediately below the last `` line: + + ```xml + $(OverrideTargetFramework) + ``` + +- Once done, if you're in Visual Studio 2022, you may need to close and re-open your solution, or otherwise click the reload button. For other IDEs, the projects will reload automatically. + +At this point, you'll notice that the list of target frameworks available in the debugger will have reduced to the list you added in `OverrideTargetFramework`. + +## Improve performance using the Uno Platform templates (5.1 and earlier) When using an Uno Platform 5.0 template, in the **Solution Explorer**, you'll find a folder named **Solution Items**, and a file named `solution-config.props.sample`. @@ -36,7 +90,15 @@ Repeat this process when changing your active development platform. > [!NOTE] > The `solution-config.props` is automatically included in a `.gitignore` file to avoid having your CI environment build only for one target. -## Improve your own solution +## Cross-targeted library builds in Visual Studio + +While building with the command line `dotnet build -f net7.0-ios` only builds the application's head and the class library for `net7.0-ios`, as of Visual Studio 17.8, class library builds are considering all target frameworks, [regardless of the project head's target framework](https://developercommunity.visualstudio.com/t/Building-a-cross-targeted-project-with-m/651372) being built. _(Please help the Uno Platform community by upvoting the issue!)_ + +Considering that during development, it is common to work on a single platform at a given time, the two sections below contain a suggested set of changes to the Uno Platform solution that can be performed on the solution to restrict the active build platform, and therefore significantly speed up build times and make intellisense respond faster. + +Choose the section that covers your cases, whether you're using a solution built using Uno Platform 5.0 templates, or if it was created with an earlier version. + +## Improve your own solution (4.9 and earlier) If you created your solution with an earlier version of Uno Platform, you can make some modifications to make your build faster: From 27114b42c3ed9bd5fe59962af306e368357c524a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Wed, 19 Jun 2024 17:03:38 -0400 Subject: [PATCH 2/2] docs: Apply suggestions from code review Co-authored-by: Andres Pineda <1900897+ajpinedam@users.noreply.github.com> --- .../guides/solution-building-single-targetframework.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/articles/guides/solution-building-single-targetframework.md b/doc/articles/guides/solution-building-single-targetframework.md index 403911623947..fc6e2b4b8305 100644 --- a/doc/articles/guides/solution-building-single-targetframework.md +++ b/doc/articles/guides/solution-building-single-targetframework.md @@ -66,9 +66,9 @@ To do so: $(OverrideTargetFramework) ``` -- Once done, if you're in Visual Studio 2022, you may need to close and re-open your solution, or otherwise click the reload button. For other IDEs, the projects will reload automatically. +- Once done, if you're in Visual Studio 2022, you may need to close and re-open your solution or otherwise click the reload button. For other IDEs, the projects will reload automatically. -At this point, you'll notice that the list of target frameworks available in the debugger will have reduced to the list you added in `OverrideTargetFramework`. +At this point, you'll notice that the list of target frameworks available in the debugger will have been reduced to the list you added in `OverrideTargetFramework`. ## Improve performance using the Uno Platform templates (5.1 and earlier) @@ -96,7 +96,7 @@ While building with the command line `dotnet build -f net7.0-ios` only builds th Considering that during development, it is common to work on a single platform at a given time, the two sections below contain a suggested set of changes to the Uno Platform solution that can be performed on the solution to restrict the active build platform, and therefore significantly speed up build times and make intellisense respond faster. -Choose the section that covers your cases, whether you're using a solution built using Uno Platform 5.0 templates, or if it was created with an earlier version. +Choose the section covering your cases, whether you're using a solution built using Uno Platform 5.0 templates or created with an earlier version. ## Improve your own solution (4.9 and earlier)