The path must be absolute. (Parameter 'root')
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
The path must be absolute. (Parameter 'root')
Expected Behavior
Upgrading vs before is good
Steps To Reproduce
Docker version 26.1.4, build 5650f9b Docker Desktop 4.31.1
Exceptions (if any)
在 Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
在 Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__1_0(String contentRoot)
在 Microsoft.AspNetCore.StaticWebAssets.ManifestStaticWebAssetFileProvider..ctor(StaticWebAssetManifest manifest, Func2 fileProviderFactory) 在 Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest) 在 Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration) 在 Microsoft.AspNetCore.Hosting.BootstrapHostBuilder.RunDefaultCallbacks() 在 Microsoft.AspNetCore.Builder.WebApplicationBuilder.InitializeHosting(BootstrapHostBuilder bootstrapHostBuilder) 在 Microsoft.AspNetCore.Builder.WebApplicationBuilder..ctor(WebApplicationOptions options, Action1 configureDefaults)
在 Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(String[] args)
在 HY.Web.Program.Main(String[] args) 在 C:\projects\XYZ.Web\Program.cs 中: 第 41 行
.NET Version
8.0.300
Anything else?
VS17.10.2
@pccai what do you mean by
Upgrading vs before is good
? Can you please provide a sample to reproduce the issue?
vs2022 17.9 it works,but up to 17.10.2 is not.
@pccai I notice you provided the docker version, but it seems like the stack is from Windows and VS. Is docker an important part of reproducing the issue? As @gfoidl mentioned, a sample app demonstrating the issue would be very helpful.
cc @javiercn, who may know more about static web assets.
I change "ASPNETCORE_ENVIRONMENT": "Development" to "ASPNETCORE_ENVIRONMENT": "Production",then it works(F5).
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": false,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_URLS": "http://+:7001",
"ASPNETCORE_ENVIRONMENT": "Production"
},
"publishAllPorts": true
},
We see the same issue in our project. When running Visual Studio v17.10.x we get the "Path must be absolute" error:
For us it seems that rolling back to Visual Studio v17.8 mitigates the issue.
We are also running a containerized app using dotnet 6, using the WSL2 based engine.
Unfortunately I can't share our solution publicly, but I'll try to create a minimal project to reproduce the issue.
I encountered the same issue when deploying my application to Azure on Ubuntu. The issue occurs when I set the ASPNETCORE_ENVIRONMENT environment variable to Development, as shown in the
When I switch the environment variable to Production, it works properly.
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.11.1 dotnet version 8
Any news on that? I'm having the same issue. Can't set the Environment to Production, since some of the logic is based on that (I want developer exceptions and so on). Any workaround? I've tried setting the ContentRoot, WebRoot to specific, rooted paths - but it doesn't seem to affect the error. It's also working absolutely correctly on Rider.
Small update from my side - I've removed the staticwebassets.runtime.json files (there were many of them, for different build configs), that were autogenerated by VS for some reason during the build process - and it went all right. Also, had to clean up all the .vs files, and, sort of, cleanup everything in the repo. I have no idea, why did VS think, that I need those, but they had incorrect references to appRoot folder (local) and they, of course, were not working correctly in Docker
And another update - try to change the webRoot folder to something else, not wwwroot. As far, as I understood - there's some sort of VS magic, that reacts to wwwroot folder inside the project folder - VS thinks, that this folder should be copied to output no matter what and generates those staticwebassets.runtime.json files with incorrect references. Then, during WebHost.CreateDefaultBuilder it tries to resolve StaticFilesManifest -> looks for those staticwebassets.runtime.json files and sets the WebRoot to the value from those files. In Production it is not triggered, since this code is executed only in Development.
I have the same problem. Waiting for a fix :-(
I had the same issue, solved by specifing a correct unix path for the PhysicalFileProvider.
just delete "Blazor.Server.staticwebassets.runtime.json" from the output directory
(file will start with your project name, some thing like blabla.Blazor.Server.staticwebassets.runtime.json)
Where is the fix? Really one year?