You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[xabt] suppress XA0101 for Razor class libraries (#10350)
Context: https://github.com/dotnet/sdk/blob/1ed2f8e9751753a1d249d129884a669363c1b832/src/StaticWebAssetsSdk/Sdk/Sdk.StaticWebAssets.StaticAssets.ProjectSystem.props#L30-L31
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2533207
1. Create a `dotnet new maui-blazor-web` project.
2. Open the `*.Shared.csproj`, the Razor class library project.
3. Change the `$(TargetFramework)` from `net9.0` to `net9.0-android`.
4. Build the project.
Get the warnings:
hellomauiblazor.Shared net9.0-android succeeded with 11 warning(s) (0.4s) → hellomauiblazor.Shared\bin\Debug\net9.0-android\hellomauiblazor.Shared.dll
wwwroot\app.css : warning XA0101: @(Content) build action is not supported
wwwroot\bootstrap\bootstrap.min.css : warning XA0101: @(Content) build action is not supported
wwwroot\bootstrap\bootstrap.min.css.map : warning XA0101: @(Content) build action is not supported
wwwroot\favicon.png : warning XA0101: @(Content) build action is not supported
Layout\MainLayout.razor : warning XA0101: @(Content) build action is not supported
Layout\NavMenu.razor : warning XA0101: @(Content) build action is not supported
Pages\Counter.razor : warning XA0101: @(Content) build action is not supported
Pages\Home.razor : warning XA0101: @(Content) build action is not supported
Pages\Weather.razor : warning XA0101: @(Content) build action is not supported
Routes.razor : warning XA0101: @(Content) build action is not supported
_Imports.razor : warning XA0101: @(Content) build action is not supported
Reviewing the code in the .NET SDK for Razor projects, they include
most of these files such as:
<!-- Publish everything under wwwroot, all JSON files, all config files and all Razor files -->
<Content Include="wwwroot\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
`%(ExcludeFromSingleFile)` looks like a useful metadata here, as
Android is basically "single file mode" no matter what. We set
`$(EnableSingleFileAnalyzers)=true` by default, so we consider mobile
a "single file" platform.
Let's suppress the `XA0101` warning for files that have
`%(ExcludeFromSingleFile)` metadata, as this seems actually
appropriate and solves the warnings in Razor class libraries.
0 commit comments