Skip to content

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
jonathanpeppers added a commit that referenced this pull request Jul 30, 2025
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.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants