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

Building assets using MSBuild & NPM needs further clarification #42409

Closed
MarkStega opened this issue Jun 24, 2022 · 5 comments
Closed

Building assets using MSBuild & NPM needs further clarification #42409

MarkStega opened this issue Jun 24, 2022 · 5 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-client-assets ✔️ Resolution: Duplicate Resolved as a duplicate of another issue question Status: Resolved

Comments

@MarkStega
Copy link

Last year @javiercn helped with a resource bundling issue (#35274). Unfortunately, there is an undesirable side-effect of the method (see the end of #42374 for a demonstration of the problem). I went back to the blog post https://devblogs.microsoft.com/dotnet/build-client-web-assets-for-your-razor-class-library/ and it appears that the reference library never made it out of the alpha stage of development. The sample app doesn't help as it is based upon the same alpha build.

My referenced csproj material.blazor.csproj does the build of js & css assets properly (and builds them only if the outputs are missing or out of date) but is apparently running the npm commands too late to have the generated assets in wwwroot recognized as static web assets.

So three questions/comments:

  1. A working demo of using npm to build static assets without the alpha library would be useful
  2. A new blog post addressing the issues revolving building static web assets would be useful
  3. Instead of content remove/include pairs in the csproj, can I just change the
BeforeTargets="PreBuildEvent"

to an earlier build step. If so, what step would be appropriate. (and are the build steps documented)?

@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-client-assets labels Jun 24, 2022
@TanayParikh
Copy link
Contributor

Hey @MarkStega, thanks for reaching out. I believe #38445 may achieve what you're looking for here.

@javiercn
Copy link
Member

@MarkStega the package in the blog post should be completely usable (it's a bunch of MSBuild) and as @TanayParikh mentions, we are productionizing a "more complete" version of the package as part of #38445 built in directly into the SDK.

For an immediate solution, I would switch to the provided package. That should do all the invocations at the right time and handle all the incrementalism.

@MarkStega
Copy link
Author

@TanayParikh Thanks, I believe I could make that work as long as I have the ability to have multiple 'generate' entries. I put in a longer comment in #38445 as to why I think that is desirable.

@javiercn I'll look at the package again but I couldn't figure out how to separate js & css builds.

@javiercn
Copy link
Member

@MarkStega the package is setup to build all the assets as a single step.

If you want to have separate sets of things to build, you can replicate what is done in the blog post to add a separate target for CSS.

The support we plan to build in the SDK will allow you to have multiple tools and commands out of the box.

@javiercn
Copy link
Member

@MarkStega we will be using #38445 to track this issue.

@javiercn javiercn added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jun 27, 2022
@ghost ghost added the Status: Resolved label Jun 27, 2022
@javiercn javiercn closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-client-assets ✔️ Resolution: Duplicate Resolved as a duplicate of another issue question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants