From 990534f8f0e1485c6700bb547c4f0418947c7cbb Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 3 Oct 2022 08:01:31 -0500 Subject: [PATCH] Build tools for .NET 6 projects under .NET 7 SDK --- aspnetcore/blazor/hosting-models.md | 4 ++-- aspnetcore/blazor/tooling.md | 17 ++++++++++++++--- .../blazor/webassembly-native-dependencies.md | 13 +++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/aspnetcore/blazor/hosting-models.md b/aspnetcore/blazor/hosting-models.md index 05a91bb011ed..540c3d8ee3d1 100644 --- a/aspnetcore/blazor/hosting-models.md +++ b/aspnetcore/blazor/hosting-models.md @@ -81,7 +81,7 @@ The Blazor WebAssembly hosting model has the following limitations: Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your .NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size. For more information, see . -The same .NET WebAssembly build tools used for AOT compilation also [relink the .NET WebAssembly runtime](xref:blazor/host-and-deploy/webassembly#runtime-relinking) to trim unused runtime code. +The same [.NET WebAssembly build tools](xref:blazor/tooling#net-webassembly-build-tools) used for AOT compilation also [relink the .NET WebAssembly runtime](xref:blazor/host-and-deploy/webassembly#runtime-relinking) to trim unused runtime code. Blazor WebAssembly includes support for trimming unused code from .NET Core framework libraries. For more information, see . The .NET compiler further precompresses a Blazor WebAssembly app for a smaller app payload. @@ -389,7 +389,7 @@ The Blazor WebAssembly hosting model has the following limitations: Blazor WebAssembly supports ahead-of-time (AOT) compilation, where you can compile your .NET code directly into WebAssembly. AOT compilation results in runtime performance improvements at the expense of a larger app size. For more information, see . -The same .NET WebAssembly build tools used for AOT compilation also [relink the .NET WebAssembly runtime](xref:blazor/host-and-deploy/webassembly#runtime-relinking) to trim unused runtime code. +The same [.NET WebAssembly build tools](xref:blazor/tooling#net-webassembly-build-tools) used for AOT compilation also [relink the .NET WebAssembly runtime](xref:blazor/host-and-deploy/webassembly#runtime-relinking) to trim unused runtime code. Blazor WebAssembly includes support for trimming unused code from .NET Core framework libraries. For more information, see . The .NET compiler further precompresses a Blazor WebAssembly app for a smaller app payload. diff --git a/aspnetcore/blazor/tooling.md b/aspnetcore/blazor/tooling.md index 4a371e60e346..eea50fc7ff10 100644 --- a/aspnetcore/blazor/tooling.md +++ b/aspnetcore/blazor/tooling.md @@ -313,7 +313,7 @@ For more information on template options, see the following resources: ## .NET WebAssembly build tools -The **.NET WebAssembly build tools** are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. To install the **.NET WebAssembly build tools**, use ***either*** of the following approaches: +The .NET WebAssembly build tools are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. To install the build tools, use ***either*** of the following approaches: * For the **ASP.NET and web development** workload in the Visual Studio installer, select the **.NET WebAssembly build tools** option from the list of optional components. * Run `dotnet workload install wasm-tools` in a command shell. @@ -1166,10 +1166,21 @@ For more information on template options, see the following resources: ## .NET WebAssembly build tools -The **.NET WebAssembly build tools** are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. To install the **.NET WebAssembly build tools**, use ***either*** of the following approaches: +The .NET WebAssembly build tools are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. To install the build tools, use ***either*** of the following approaches: * For the **ASP.NET and web development** workload in the Visual Studio installer, select the **.NET WebAssembly build tools** option from the list of optional components. -* Run `dotnet workload install wasm-tools` in a command shell. +* Execute `dotnet workload install wasm-tools` in an administrative command shell. + +> [!NOTE] +> .NET WebAssembly build tools for .NET 6 projects +> +> The `wasm-tools` workload installs the build tools for .NET 7 projects. However, the .NET 7 version of the build tools are incompatible with existing projects built with .NET 6. Projects using the build tools that must support both .NET 6 and .NET 7 must use multi-targeting. +> +> Use the `wasm-tools-net6` workload for .NET 6 projects when developing apps with the .NET 7 SDK. To install the `wasm-tools-net6` workload, execute the following command from an administrative command shell: +> +> ```dotnetcli +> dotnet workload install wasm-tools-net6 +> ``` For more information, see the following resources: diff --git a/aspnetcore/blazor/webassembly-native-dependencies.md b/aspnetcore/blazor/webassembly-native-dependencies.md index 4dea3cc40324..320f1d330735 100644 --- a/aspnetcore/blazor/webassembly-native-dependencies.md +++ b/aspnetcore/blazor/webassembly-native-dependencies.md @@ -16,12 +16,9 @@ Blazor WebAssembly apps can use native dependencies built to run on WebAssembly. ## .NET WebAssembly build tools -The **.NET WebAssembly build tools** are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. To install the **.NET WebAssembly build tools**, use ***either*** of the following approaches: +The .NET WebAssembly build tools are based on [Emscripten](https://emscripten.org/), a compiler toolchain for the web platform. For more information on the build tools, including installation, see . -* For the **ASP.NET and web development** workload in the Visual Studio installer, select the **.NET WebAssembly build tools** option from the list of optional components. -* Run `dotnet workload install wasm-tools` in a command shell. - -Add native dependencies to a Blazor WebAssembly app by adding `NativeFileReference` items in the app's project file. When the project is built, each `NativeFileReference` is passed to Emscripten by the **.NET WebAssembly build tools** so that they are compiled and linked into the runtime. Next, [`p/invoke`](/dotnet/standard/native-interop/pinvoke) into the native code from the app's .NET code. +Add native dependencies to a Blazor WebAssembly app by adding `NativeFileReference` items in the app's project file. When the project is built, each `NativeFileReference` is passed to Emscripten by the .NET WebAssembly build tools so that they are compiled and linked into the runtime. Next, [`p/invoke`](/dotnet/standard/native-interop/pinvoke) into the native code from the app's .NET code. Generally, any portable native code can be used as a native dependency with Blazor WebAssembly. You can add native dependencies to C/C++ code or code previously compiled using Emscripten: @@ -83,7 +80,7 @@ Add a simple native C function to a Blazor WebAssembly app: } ``` -When you build the app with the **.NET WebAssembly build tools** installed, the native C code is compiled and linked into the .NET WebAssembly runtime (`dotnet.wasm`). After the app is built, run the app to see the rendered factorial value. +When you build the app with the .NET WebAssembly build tools installed, the native C code is compiled and linked into the .NET WebAssembly runtime (`dotnet.wasm`). After the app is built, run the app to see the rendered factorial value. ## C++ managed method callbacks @@ -152,3 +149,7 @@ To use SkiaSharp in a Blazor WebAssembly app: ``` 1. Build the app, which might take several minutes. Run the app and navigate to the `NativeDependencyExample` component at `/native-dependency-example`. + +## Additional resources + +* [.NET WebAssembly build tools](xref:blazor/tooling#net-webassembly-build-tools)