Skip to content

RCL + Libman: Restored files don't get packed / published at the correct location in final app. #634

Open
@TFTomSun

Description

@TFTomSun

Copy from the original issue I filed in the AspNet.Core repo:
dotnet/aspnetcore#34039

Describe the bug

Files that are restored with the Microsoft.Web.LibraryManager.Build (LibMan) inside a Razor Class Library (RCL) are not deployed to the correct location in the final consuming app (e.g. Blazor Server App).
Instead of being deployed to:
wwwroot/_content/<RCL Package Name>/
they are deployed to
wwwroot/

This happens only if the files are not yet restored when you pack / publish the app. Once the files are restore they are correctly deployed in subsequent builds.

dotnet version:
5.0.300
environments:
dotnet cli (e.g. dotnet pack)
Visual Studio (pack context menu)

Solution

I found out that the ResolveCurrentProjectStaticWebAssetsInputs target takes content files as its input. The LibraryManagerRestore on the other hand doesn't produce content items. If you apply the following workaround, the issue disappears:

...
  <PropertyGroup>

<ResolveCurrentProjectStaticWebAssetsInputsDependsOn>LibraryManagerRestore;FixLibManRestore;$(ResolveCurrentProjectStaticWebAssetsInputsDependsOn)</ResolveCurrentProjectStaticWebAssetsInputsDependsOn>

  </PropertyGroup>
  
  <Target Name="FixLibManRestore" AfterTargets="LibraryManagerRestore">
  <ItemGroup>
            <Content  Include="%(FilesForPackagingFromProject.Identity)" Exclude="@(Content)">
            </Content>
        </ItemGroup>
		
  </Target>

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions