Skip to content

Commit cc40abb

Browse files
authored
RCLs for Blazor apps that support pages+views (#32458)
1 parent 91ea95e commit cc40abb

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

aspnetcore/blazor/components/class-libraries.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,37 @@ If the **Support pages and views** checkbox is selected to support pages and vie
4747
@using Microsoft.AspNetCore.Components.Web
4848
```
4949

50-
* Add the following `SupportedPlatform` item to the project file (`.csproj`):
50+
* Add the following `SupportedPlatform` item and package reference for [`Microsoft.AspNetCore.Components.Web`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.Web) to the project file (`.csproj`):
5151

5252
```xml
5353
<ItemGroup>
5454
<SupportedPlatform Include="browser" />
5555
</ItemGroup>
56+
57+
<ItemGroup>
58+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="{VERSION}" />
59+
</ItemGroup>
5660
```
5761

62+
In the preceding example, the `{VERSION}` placeholder is the package version.
63+
64+
> [!IMPORTANT]
65+
> When a Razor class library is added to a solution with the **Support pages and views** checkbox selected, the library also references the [`Microsoft.AspNetCore.App` ASP.NET Core shared framework](xref:fundamentals/metapackage-app):
66+
>
67+
> ```xml
68+
> <ItemGroup>
69+
> <FrameworkReference Include="Microsoft.AspNetCore.App" />
70+
> </ItemGroup>
71+
> ```
72+
>
73+
> The shared framework isn't supported on Blazor WebAssembly, so libraries that target client-side apps should remove the framework reference. When the library targets both server-side and client-side apps, control the dependency with an [MSBuild condition](/visualstudio/msbuild/msbuild-conditions):
74+
>
75+
> ```xml
76+
> <ItemGroup Condition="'$(IsWasmProject)' != 'true'">
77+
> <FrameworkReference Include="Microsoft.AspNetCore.App" />
78+
> </ItemGroup>
79+
> ```
80+
5881
For more information on the `SupportedPlatform` item, see the [client-side browser compatibility analyzer](#client-side-browser-compatibility-analyzer) section.
5982
6083
:::moniker-end
@@ -93,14 +116,37 @@ If the `-s|--support-pages-and-views` option is used to support pages and views
93116
@using Microsoft.AspNetCore.Components.Web
94117
```
95118

96-
* Add the following `SupportedPlatform` item to the project file (`.csproj`):
119+
* Add the following `SupportedPlatform` item and package reference for [`Microsoft.AspNetCore.Components.Web`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.Web) to the project file (`.csproj`):
97120

98121
```xml
99122
<ItemGroup>
100123
<SupportedPlatform Include="browser" />
101124
</ItemGroup>
125+
126+
<ItemGroup>
127+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="{VERSION}" />
128+
</ItemGroup>
102129
```
103130

131+
In the preceding example, the `{VERSION}` placeholder is the package version.
132+
133+
> [!IMPORTANT]
134+
> When a Razor class library is added to a solution with the **Support pages and views** checkbox selected, the library also references the [`Microsoft.AspNetCore.App` ASP.NET Core shared framework](xref:fundamentals/metapackage-app):
135+
>
136+
> ```xml
137+
> <ItemGroup>
138+
> <FrameworkReference Include="Microsoft.AspNetCore.App" />
139+
> </ItemGroup>
140+
> ```
141+
>
142+
> The shared framework isn't supported on Blazor WebAssembly, so libraries that target client-side apps should remove the framework reference. When the library targets both server-side and client-side apps, control the dependency with an [MSBuild condition](/visualstudio/msbuild/msbuild-conditions):
143+
>
144+
> ```xml
145+
> <ItemGroup Condition="'$(IsWasmProject)' != 'true'">
146+
> <FrameworkReference Include="Microsoft.AspNetCore.App" />
147+
> </ItemGroup>
148+
> ```
149+
104150
For more information on the `SupportedPlatform` item, see the [client-side browser compatibility analyzer](#client-side-browser-compatibility-analyzer) section.
105151
106152
:::moniker-end

0 commit comments

Comments
 (0)