Skip to content

[xabt] suppress XA0101 for Razor class libraries #10350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025

Conversation

jonathanpeppers
Copy link
Member

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.

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.
@jonathanpeppers jonathanpeppers enabled auto-merge (squash) July 28, 2025 19:06
@jonathanpeppers jonathanpeppers self-assigned this Jul 28, 2025
@jonathanpeppers jonathanpeppers merged commit 70f4dd8 into main Jul 28, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/XA0101 branch July 28, 2025 21:40
@github-project-automation github-project-automation bot moved this from In Progress to Done in .NET for Android Backlog Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant