dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.07k stars 9.9k forks source link

The path must be absolute. (Parameter 'root') #56416

Open pccai opened 2 months ago

pccai commented 2 months ago

Is there an existing issue for this?

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.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

gfoidl commented 1 month ago

@pccai what do you mean by

Upgrading vs before is good

? Can you please provide a sample to reproduce the issue?

pccai commented 1 month ago

vs2022 17.9 it works,but up to 17.10.2 is not.

amcasey commented 1 month ago

@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.

amcasey commented 1 month ago

cc @javiercn, who may know more about static web assets.

pccai commented 1 month ago

I change "ASPNETCORE_ENVIRONMENT": "Development" to "ASPNETCORE_ENVIRONMENT": "Production",then it works(F5).

pccai commented 1 month ago
"Container (Dockerfile)": {
  "commandName": "Docker",
  "launchBrowser": false,
  "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
  "environmentVariables": {
    "ASPNETCORE_URLS": "http://+:7001",
    "ASPNETCORE_ENVIRONMENT": "Production"
  },
  "publishAllPorts": true
},
AdeZwart commented 1 month ago

We see the same issue in our project. When running Visual Studio v17.10.x we get the "Path must be absolute" error: image

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.