Skip to content
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

[Blazor] libman libraries not included in first build #6709

Closed
campersau opened this issue Apr 30, 2022 · 1 comment
Closed

[Blazor] libman libraries not included in first build #6709

campersau opened this issue Apr 30, 2022 · 1 comment
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external platform/windows 🪟 t/bug Something isn't working

Comments

@campersau
Copy link
Contributor

Description

Adding some client javascript libraries via libman does not include them in the first build.
When comparing the binlog with a blazor wasm build I can see that there is a _IncludePrePublishGeneratedContent target which is not present in the blazor maui build and thus any files which are generated under the wwwroot folder during the build are missing.

Here are the binlogs:
blazorbinlogs.zip

I only tested windows.

Steps to Reproduce

  1. New Blazor Maui App
  2. Add <PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.161" PrivateAssets="all" /> to the csproj
  3. Add libman.json with the following content:
{
  "version": "1.0",
  "defaultProvider": "cdnjs",
  "libraries": [
    {
      "library": "[email protected]",
      "files": [
        "css/bootstrap.min.css"
      ],
      "destination": "wwwroot/libs/bootstrap"
    }
  ]
}
  1. Update index.html and reference <link rel="stylesheet" href="libs/bootstrap/css/bootstrap.min.css" /> instead.
  2. Remove the wwwroot/libs folder and do a new build / run. This will add the libs folder back but the app does include the CSS file. If you run the app again without removing the wwwroot/libs folder the CSS is included correctly.

It would be great if the libman library files were included directly in the first build.

Alternatively you can clone https://github.com/campersau/blazor-maui-libmanbug and do step 5.

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net6.0-windows10.0.19041.0

Did you find any workaround?

Building the project a second time works correctly as the libraries are already restored.

Or copy the msbuild target from https://github.com/dotnet/sdk/blob/c53c8ac81e1bcb8118c31bc4f5622396c72e9959/src/WebSdk/Publish/Targets/ComputeTargets/Microsoft.NET.Sdk.Publish.ComputeFiles.targets#L48-L60 into the csproj.

<Target Name="_IncludePrePublishGeneratedContent" BeforeTargets="GetCopyToPublishDirectoryItems" Condition=" '$(EnableDefaultItems)' == 'true' And '$(EnableDefaultContentItems)' == 'true' ">
    <ItemGroup>
        <!-- First, clean up previously generated content that may have been removed. -->
        <ContentWithTargetPath Remove="@(ContentWithTargetPath)" Condition="!Exists('%(Identity)')" />
        <!-- Next, include any newly generated content. -->
        <_WebProjectGeneratedContent Include="wwwroot\**" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);@(_ContentIncludedByDefault)" />
        <ContentWithTargetPath Include="@(_WebProjectGeneratedContent)" TargetPath="%(Identity)" CopyToPublishDirectory="PreserveNewest" />
    </ItemGroup>
</Target>

Relevant log output

No response

@campersau campersau added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 30, 2022
@jfversluis jfversluis added area-blazor Blazor Hybrid / Desktop, BlazorWebView and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels May 2, 2022
@javiercn
Copy link
Member

javiercn commented May 2, 2022

This issue was moved to aspnet/LibraryManager#680

@dotnet dotnet locked and limited conversation to collaborators May 2, 2022
@javiercn javiercn closed this as completed May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants