dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

Issue with running hosted Blazer WebAssembly app caused by props file contents #47135

Closed vnbaaij closed 1 year ago

vnbaaij commented 1 year ago

Is there an existing issue for this?

Describe the bug

In the Microsoft.Fast.Components.FluentUI package I'm using the package .props file to define some properties. Everything works ok when consuming the package and running a Blazor Server or Blazor WebAssembly application stand-alone. The application does not load when run in a hosted Blazor WebAssembly project. The application then cannot find and load any static assets. The problem is solved by changing the order of the contents in the .props file in the package.

Contents of the props file when the error/hang occurs:

<Project>
    <ItemGroup>
        <CompilerVisibleProperty Include="PublishFluentIconAssets" />
        <CompilerVisibleProperty Include="PublishFluentEmojiAssets" />
        <CompilerVisibleProperty Include="FluentEmojiStyles" />
        <CompilerVisibleProperty Include="FluentEmojiGroups" />
        <CompilerVisibleProperty Include="FluentIconSizes" />
        <CompilerVisibleProperty Include="FluentIconVariants" />
    </ItemGroup>
    <PropertyGroup>
        <PublishFluentIconAssets Condition="'$(PublishFluentIconAssets)' == ''" >false</PublishFluentIconAssets>
        <PublishFluentEmojiAssets Condition="'$(PublishFluentEmojiAssets)' == ''" >false</PublishFluentEmojiAssets>

        <FluentIconSizes Condition="'$(FluentIconSizes)' == ''">10,12,16,20,24,28,32,48</FluentIconSizes>
        <FluentIconVariants Condition="'$(FluentIconVariants)' == ''">Filled,Regular</FluentIconVariants>
        <FluentEmojiGroups Condition="'$(FluentEmojiGroups)' == ''">Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
        <FluentEmojiStyles Condition="'$(FluentEmojiStyles)' == ''">Color,Flat,HighContrast</FluentEmojiStyles>
    </PropertyGroup>
    <Import Project="Microsoft.AspNetCore.StaticWebAssets.props" />
</Project>

Contents of the props file when problem does not occur:

<Project>
    <Import Project="Microsoft.AspNetCore.StaticWebAssets.props" />
    <ItemGroup>
        <CompilerVisibleProperty Include="PublishFluentIconAssets" />
        <CompilerVisibleProperty Include="PublishFluentEmojiAssets" />
        <CompilerVisibleProperty Include="FluentEmojiStyles" />
        <CompilerVisibleProperty Include="FluentEmojiGroups" />
        <CompilerVisibleProperty Include="FluentIconSizes" />
        <CompilerVisibleProperty Include="FluentIconVariants" />
    </ItemGroup>
    <PropertyGroup>
        <PublishFluentIconAssets Condition="'$(PublishFluentIconAssets)' == ''" >false</PublishFluentIconAssets>
        <PublishFluentEmojiAssets Condition="'$(PublishFluentEmojiAssets)' == ''" >false</PublishFluentEmojiAssets>

        <FluentIconSizes Condition="'$(FluentIconSizes)' == ''">10,12,16,20,24,28,32,48</FluentIconSizes>
        <FluentIconVariants Condition="'$(FluentIconVariants)' == ''">Filled,Regular</FluentIconVariants>
        <FluentEmojiGroups Condition="'$(FluentEmojiGroups)' == ''">Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
        <FluentEmojiStyles Condition="'$(FluentEmojiStyles)' == ''">Color,Flat,HighContrast</FluentEmojiStyles>
    </PropertyGroup>
</Project>

Expected Behavior

I expect the order of the lines in the .props file to not have any influence on the working of an application that consumes my package.

Steps To Reproduce

-Create a NuGet package with a custom .props file that has more content then just the Import statement where the import statement is last -Create a hosted Blazor project that consumes the package -Verify the app does not load when running it -Change the .props file so the import statement comes first and recreate the package -Change the project to use the new package -Verify the app runs properly

If a starting point is wanted, the https://github.com/microsoft/fast-blazor repo can be used for this.

Exceptions (if any)

No response

.NET Version

.NET 6, .NET 7

Anything else?

8315d771-ffc3-429a-8088-46908ed0c82c

javiercn commented 1 year ago

@vnbaaij what are you putting in your Microsoft.AspNetCore.StaticWebAssets.props file.

I expect the order of the lines in the .props file to not have any influence on the working of an application that consumes my package.

Order absolutely matters in MSBuild. See here for details.

If this is an issue at all (which I do not necessarily thing it is) is likely a bug in your own targets/props files, unless you have a binlog that shows exactly that some evaluation of the pipeline does not reflect the defined behavior by MSBuild.

ghost commented 1 year ago

Hi @vnbaaij. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

vnbaaij commented 1 year ago

@vnbaaij Vincent Baaij FTE what are you putting in your Microsoft.AspNetCore.StaticWebAssets.props file.

That contains just the standard generated static assets xml (i.e. generated from the files in the wwwroot folder):

<Project>
  <ItemGroup>
    <StaticWebAsset Include="$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\Components\Anchor\FluentAnchor.razor.js))">
      <SourceType>Package</SourceType>
      <SourceId>Microsoft.Fast.Components.FluentUI</SourceId>
      <ContentRoot>$(MSBuildThisFileDirectory)..\staticwebassets\</ContentRoot>
      <BasePath>_content/Microsoft.Fast.Components.FluentUI</BasePath>
      <RelativePath>Components/Anchor/FluentAnchor.razor.js</RelativePath>
      <AssetKind>All</AssetKind>
      <AssetMode>All</AssetMode>
      <AssetRole>Primary</AssetRole>
      <RelatedAsset></RelatedAsset>
      <AssetTraitName></AssetTraitName>
      <AssetTraitValue></AssetTraitValue>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      <OriginalItemSpec>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\staticwebassets\Components\Anchor\FluentAnchor.razor.js))</OriginalItemSpec>
    </StaticWebAsset>
:
:
 </ItemGroup>
</Project>
ghost commented 1 year ago

Hi @vnbaaij. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!