-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Rebuild fails when fingerprinting compiled TypeScript in VS 17.12.0 #58948
Comments
I also get this problem in .NET 8 Microsoft.NET.Sdk.Razor projects after installing .NET 9 SDK / VS 17.12:
The .css files are compiled with BuildWebCompiler2022 from .scss. |
@javiercn @halter73 this issue also got reported as a regression with VS 17.12 on Developer Community here. Many customers are reporting it. Can you investigate and help determine if the issue is on the runtime side or tooling? Thanks! cc: @mkArtakMSFT |
As suggested elsewhere - adding a "global.json" to the root of your solution with the following will target the 8.0 SDK as a short term workaround. { |
非常感谢你,按你的方法已解决了我的问题: |
Thanks for reporting this issue, everyone. For now, can you please try to disable the fingerprinting until we get to the bottom of this and address it: <StaticWebAssetFingerprintingEnabled>false</StaticWebAssetFingerprintingEnabled> |
The project doesn't seem to be following the guidance that we provide here. Although that documentation seems to be slightly out of date. + <PrepareForBuildDependsOn>
+ CompileTypeScriptWithTSConfig;
+ GetTypeScriptOutputForPublishing;$(PrepareForBuildDependsOn)
+ </PrepareForBuildDependsOn>
</PropertyGroup>
+ <ItemGroup>
+ <Content Remove="wwwroot\js\**" />
+ </ItemGroup>
|
@balachir check the comment above, the likely cause has been that |
dotnet/AspNetCore.Docs#34165 <- Tracks updating the docs. For people using other tools to compile/generate assets, make sure that you use https://learn.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-9.0&tabs=visual-studio#add-client-web-assets-to-the-build-process. Or if you are wiring your own target, it needs to be wired up before static web assets are discovered, typically, |
If i publish my project with the above markup added to the .csproj the generated .js files are not included in the published output, which defeats the entire purpose...
I think this is probably at the core of the issue - it has always seemed as if things are built or checked in the wrong order. It seems strange to me, however, that this dependency chain is not automatically enforced by the TS build target or similar...
Could you please help me understand how this solves the issue - yes, it builds but only because the generated output is ignored and excluded from publish? I mean, what's the point then? |
For css files that were minified using https://marketplace.visualstudio.com/items?itemName=Failwyn.BundlerMinifier64 it worked for me with: <PropertyGroup>
<PrepareForBuildDependsOn>
BundleMinify;$(PrepareForBuildDependsOn)
</PrepareForBuildDependsOn>
</PropertyGroup> If you are using something else to minify, you will have to find out what they called their build target. For Typescript I followed the suggestion with the following config: <PropertyGroup>
<PrepareForBuildDependsOn>
CompileTypeScriptWithTSConfig;
GetTypeScriptOutputForPublishing;$(PrepareForBuildDependsOn)
</PrepareForBuildDependsOn>
</PropertyGroup> But now I get this error (even with the
|
This is because the typescript compiler adds the elements as I'll post an updated fix and we will document this in the docs. |
The missing piece is this one target that removes existing content items before + <Target Name="RemoveDuplicateTypeScriptOutputs" BeforeTargets="GetTypeScriptOutputForPublishing">
+ <ItemGroup>
+ <Content Remove="@(GeneratedJavaScript)" />
+ </ItemGroup>
+ </Target> |
I've filed microsoft/TypeScript#60538 on the typescript repository to improve the integration with ASP.NET Core, I suggest you go and upvote the issue to show interest. Hopefully we can make this just work out of the box. For other tools, hooking to |
@javiercn I'm sorry if this information is readily available elsewhere, but is there a difference between adding a task to the |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
I've been experiencing a similar error for an ASP.NET Core MVC project that I updated to .NET 9. In the end, this is my workaround: Don't use rebuild, use clean + build instead The workaround with |
@Liebeck >
That is not a viable option for our build server, or for our devs in the long run. We've had some limited success with the proposed solution by @javiercn but it leads to other build problems, in particular with our MAUI hybrid project. I will probably open up a second issue once I have a new minimal repro prepared. For now our only workaround is still the
Yeah, we've had the same experience. That's why I mentioned in the original post that it's unclear why fingerprinting is running and how to turn it off. |
For css files that were minified using https://www.nuget.org/packages/BuildWebCompiler2022 it worked for me with:
|
Well I'd like to add that I use both Mads BuildWebCompiler and BuildBundlerMinifier and this worked for me:
|
This does indeed prevent the error, but it seems to cause other issues. If I rebuild multiple times in a row, the generated files get deleted at the end of every other rebuild. |
I'm going to say it, and I'm sure that some people might interpret this as not helpful. As someone who has been bit repeatedly by releases of the StaticWebAssets SDK (including this one) throughout the .NET 9.0 release cycle, I feel I deserve to say it: This SDK feels too rushed out the door for such a minimal impact on the platform. It doesn't feel like there were any real-world unit and integration tests built to handle the different ways that compiled assets are used on Blazor code, and that's why you're seeing the issues you are today. I hope building this did not take away resources from Blazor Multithreading. |
Furthermore, I just realized that using MapStaticAssets messes with my API GET endpoints -- but only under Development build. Freaked me out at first. Had to crawl through the source code to find that setting Note that there are 2 other dev settings as well: So it seems that MapStaticAssets also checks your api endpoints for static resources? |
But doesn't work for .net8.0. So our compiles with |
Yep, which is what I (and literally anyone else who makes Blazor assemblies) am targeting right now in my projects. Also, this thread needs to be re-opened because there is not actually a functioning fix yet. |
I'm still getting this error, but with an html file that is minified during our build process. Only happens in azure pipelines (works locally). This prevents us with moving forward with dotnet 9 |
Is there an existing issue for this?
Describe the bug
After upgrading to VS 17.12.0 / .Net9 SDK: Solution Rebuild fails during fingerprinting of static assets, if those assets are (re-)produced during build.
In particular this applies to TypeScript files that are compiled to
.js
files underwwwroot/
during the build process, using the standardMicrosoft.TypeScript.MSBuild
(5.6.2) nuget.This worked in VS 17.11.x / .Net8 SDK.
The project is a .Net8 project.
NB: It is also unclear why fingerprinting is even applied to .Net8 projects, and how to turn it off.
Expected Behavior
Rebuild should not fail. Analysis of static assets produced during build should be scheduled so that fingerprinting succeeds.
Steps To Reproduce
Minimal repro here: https://github.com/kaleidocore/TSBuildFail
The minimal repro is based on the basic TypeScript template/example described here: https://learn.microsoft.com/en-us/visualstudio/javascript/tutorial-aspnet-with-typescript?view=vs-2022
Typically Clean+Build succeeds, but Rebuild fails.
Exceptions (if any)
.NET Version
9.0.100
Anything else?
Other static assets produced during build also fails in the same way, e.g. .scss -> .css using WebCompiler.
A temporary workaround for the issue is to force a downgrade of the .Net SDK using a
global.json
in the root folder:I believe the core of this issue is actually much older, but the new Fingerprinting feature puts focus on it by failing completely, whereas it previously sort of "worked" - we have had very similar issues when publishing our projects (
dotnet publish solution.sln ...
) in previous versions of Visual Studio / .Net. It often appears random or timing based whether those same static files produced during build are actually included in the publish output. We've had to work around it by adding additional build steps such as Clean, Build, Publish and running it single-threaded.I also suspect these issues are related:
#57147
#58748
The text was updated successfully, but these errors were encountered: