-
Notifications
You must be signed in to change notification settings - Fork 10.3k
MSB4018: The "DefineStaticWebAssetEndpoints" task failed unexpectedly. #58975
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
Comments
What happens if you remove (for testing) the file with the non-ascii file name? (\Grünerløkka--w1920_jpg.webp) |
Then it works. I already removed all of them. Annoying is that it stops on first (not sure if it is default or my VS settings) so cleaning them manually is not fun :/ |
@jirisykora83 thanks for contacting us. We'll take a look, in the mean time, you can exclude those files from the If you have a repro project that will definitely help. Additionally, is there any tool that you are using to generate those files? |
No, it just caches files in wwwroot during runtime as this works well (no need to download again as it is semi-expensive operation). Deployed app use CDN but localhost not. For replication i try to isolate the issue as much as possible. |
@jirisykora83 thanks for the additional details. So, to make sure that we understand, you are generating some cache files at runtime and placing them inside the wwwroot folder (with the idea that they can be served as assets at that point?) or does that cache gets populated as part of the build? I imagine that what we need to do here is percent encode the url |
Yes exactly. Error then happens during local build when app previously runs (download some files). -- I'm not sure about this because if the file is not in the folder it may work. Maybe the issue is not about the file name itself but the whole path. I am not sure. |
@jirisykora83 thanks for the additional details. So, what's happening here is that on the initial build things work and on additional builds (after the app has run and generated additional files) those files are then considered static assets and cause the build to fail (given the issue above). We will likely address this issue, however, even in that case, you should consider changing your approach. One way to do this is to create a It is best to keep your cache content separate from your static files content as they have very different lifecycles and constraints. As of .NET 9.0, a lot of build/publish time optimizations will apply to the files in the |
Is there an existing issue for this?
Describe the bug
New StaticWebAssets make build fail. Mostly likely because of weird file names.
1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: The "DefineStaticWebAssetEndpoints" task failed unexpectedly. 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: System.IO.FileNotFoundException: Could not find file 'wwwroot\images\7474b9fd-5ab7-4c37-83ad-5e954a8cc7fb\Grünerløkka--w1920_jpg.webp'. 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: File name: 'wwwroot\images\7474b9fd-5ab7-4c37-83ad-5e954a8cc7fb\Grünerløkka--w1920_jpg.webp' 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at System.IO.FileInfo.get_Length() 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.GetFileLength(StaticWebAsset asset) 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.CreateEndpoints(StaticWebAsset asset, ContentTypeProvider contentTypeMappings) 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssetEndpoints.Execute() 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Execute() 1>C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(675,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Is there any option to disable new StaticWebAssets for specific folder (in this case it is just "cache" as images are loaded from API and store in wwwroot). It should be an issue, just for dev build (i guess - not ready to deploy).
Even if the option for excluding folder exists, I still think this should not happen.
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
9.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: