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

Use of --no-build with dotnet publish breaks content with .NET 9 #2778

Closed
craigktreasure opened this issue Oct 8, 2024 · 8 comments
Closed
Labels
status:needs-investigation Needs additional investigation

Comments

@craigktreasure
Copy link
Member

craigktreasure commented Oct 8, 2024

🐛 Bug Report

Summary

  • Change in behavior for dotnet publish --no-build when using .NET 9.
  • When the *.publish.manifest.json resources are not named properly, there is no error indication as to what the problem is.

Explanation

Upon upgrading to .NET 9, my production endpoint began showing as blank. No errors in the console and no 404 errors retrieving resources. Inspecting the page, the body tag has a hidden-body class causing it to be...well...hidden. The loading-theme component also has mode="null", which isn't expected:

<loading-theme storage-name="theme">
  <fluent-design-theme mode="null" primary-color="Default"></fluent-design-theme>
</loading-theme>

If I remove the hidden-body class exposing the page, the theme is not correct. If I attempt to interact with the theme components, I start to see errors in the console:

Error: Microsoft.JSInterop.JSException: Cannot read properties of undefined (reading 'clearLocalStorage')
TypeError: Cannot read properties of undefined (reading 'clearLocalStorage')

None of this occurred building locally whether in or out of a container. I could, however, pull the production container produced by my CI and reproduce the issue.

After more head scratching than I'd care to admit, I discovered that my CI build does dotnet publish --no-build. After comparing the build artifacts, I discovered some files in the wwwroot folder that were different.

.NET 8 with dotnet publish --no-build:
• wwwroot/MyProjectName.publish.manifest.json

.NET 9 with dotnet publish --no-build:
• wwwroot/jsmodules.publish.manifest.json
• wwwroot/jsmodules.publish.manifest.json.br
• wwwroot/jsmodules.publish.manifest.json.gz

.NET 9 with dotnet publish (--no-build removed):
• wwwroot/MyProjectName.publish.manifest.json
• wwwroot/MyProjectName.publish.manifest.json.br
• wwwroot/MyProjectName.publish.manifest.json.gz

The contents of the json files are exactly the same.

It appears that something in .NET 9 with regards to the use of --no-build has changed copying the files with unexpected names.

💻 Repro or Code Sample

Build a .NET 9 Blazor project using the following:

dotnet build -c Release
# I typically run `dotnet test -c Release --no-build` here before publishing
dotnet publish --no-build # `dotnet publish` does Release configuration by default these days

This will produce the following files in the publish output:
• wwwroot/jsmodules.publish.manifest.json
• wwwroot/jsmodules.publish.manifest.json.br
• wwwroot/jsmodules.publish.manifest.json.gz

🤔 Expected Behavior

The MyProjectName.publish.manifest.json* files should be produced in the publish output as expected.

dotnet build -c Release
# I typically run `dotnet test -c Release --no-build` here before publishing
dotnet publish --no-build # `dotnet publish` does Release configuration by default these days

The commands above should produce the following files named with MyProjectName.* rather than jsmodules.*:
• wwwroot/MyProjectName.publish.manifest.json
• wwwroot/MyProjectName.publish.manifest.json.br
• wwwroot/MyProjectName.publish.manifest.json.gz

In .NET 8, everything worked as expected with the use of --no-build.

😯 Current Behavior

dotnet build -c Release
# I typically run `dotnet test -c Release --no-build` here before publishing
dotnet publish --no-build # `dotnet publish` does Release configuration by default these days

The commands above produce the following files incorrectly named:
• wwwroot/jsmodules.publish.manifest.json
• wwwroot/jsmodules.publish.manifest.json.br
• wwwroot/jsmodules.publish.manifest.json.gz

When you run the application in this way, you'll get a blank screen with no errors in the console and no network request errors. There's not much indication as to what went wrong or what's missing.

💁 Possible Solution

Current workaround is to remove the use of the --no-build parameter for the publish command.

🔦 Context

I typically use --no-build to speed up the publish command a bit. Also, it just seems unnecessary to allow further build after you've already performed a build.

🌍 Your Environment

  • OS & Device: Windows 11 and Ubuntu 22.04 (WSL)
  • Browser: Microsoft Edge
  • .NET: 9.0.100-rc.1.24452.12
  • Fluent UI Blazor library Version: 4.10.1
@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label Oct 8, 2024
@vnbaaij
Copy link
Collaborator

vnbaaij commented Oct 8, 2024

Thank you for the comprehensive issue report! I can see that this is a problem, but I am unsure if there is anything we can do about it. I don't want it to appear as if I'm sending you off into the woods, but I think this is more an issue that should be raised in the ASP.NET Core repo. Don't you think so?

@vnbaaij vnbaaij added status:needs-investigation Needs additional investigation and removed triage New issue. Needs to be looked at labels Oct 8, 2024
@craigktreasure
Copy link
Member Author

Ha. Yes. You're absolutely right. I initially thought it was a Fluent UI problem and got so caught up in writing the report that I misplaced it. I'll refile in ASP.NET.

@vnbaaij
Copy link
Collaborator

vnbaaij commented Oct 8, 2024

Ok, closing this one on this side then.

@vnbaaij vnbaaij closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
@craigktreasure
Copy link
Member Author

@vnbaaij Do you happen to know what produces the jsmodules.publish.manifest.json file?

@vnbaaij
Copy link
Collaborator

vnbaaij commented Oct 11, 2024

I'm guessing it is coming from our Core.Assets project (which is an .esproj). When I run dotnet publish --no-build -f net9.0 on the core project, it produces a wwwroot folder with the three jsmodules.publish.manifest.json.* files. Inside the non-packed one it has:

[
  "Microsoft.FluentUI.AspNetCore.Components.lib.module.js"
]

@maot01
Copy link

maot01 commented Nov 29, 2024

I would just like to leave this here. But this happened for us as well, and we were running .net 8.0.x. Probably some small change by Microsoft changed this. Removing --no-build resolved it.

@craigktreasure
Copy link
Member Author

I would just like to leave this here. But this happened for us as well, and we were running .net 8.0.x. Probably some small change by Microsoft changed this. Removing --no-build resolved it.

See dotnet/aspnetcore#58321

@maot01
Copy link

maot01 commented Dec 2, 2024

I would just like to leave this here. But this happened for us as well, and we were running .net 8.0.x. Probably some small change by Microsoft changed this. Removing --no-build resolved it.

See dotnet/aspnetcore#58321

Yes, but in our case, we were not even using .net 9 SDK, but .net 8 SDK. Just FYI 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-investigation Needs additional investigation
Projects
None yet
Development

No branches or pull requests

3 participants