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.21k stars 9.95k forks source link

running error "The path must be absolute." #35285

Closed timeshift92 closed 3 years ago

timeshift92 commented 3 years ago

error on bare template

Describe the bug

ran the template in docker and got an error when running on windows everything is fine

To Reproduce

create .net core web application with docker (linux)

Exceptions (if any)

Exception thrown: 'System.ArgumentException' in Microsoft.Extensions.FileProviders.Physical.dll
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.Extensions.FileProviders.Physical.dll: 'The path must be absolute.'
Stack trace:
 >   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
 >   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)
 >   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__2_1(String contentRoot)
 >   at Microsoft.AspNetCore.Hosting.StaticWebAssets.ManifestStaticWebAssetFileProvider..ctor(StaticWebAssetManifest manifest, Func`2 fileProviderFactory)
 >   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest, Boolean isJson)
 >   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)
 >   at Microsoft.AspNetCore.Hosting.BootstrapHostBuilder.RunConfigurationCallbacks()
 >   at Microsoft.AspNetCore.Builder.WebApplicationBuilder..ctor(Assembly callingAssembly, String[] args)
 >   at Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(String[] args)
 >   at <Program>$.<Main>$(String[] args) in C:\PROJECTS\Others\Uztelecom\Uztelecom.Web\Program.cs:line 2

Further technical details

Runtime Environment: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\

Host (useful for support): Version: 6.0.0-preview.7.21377.19 Commit: 91ba01788d

.NET SDKs installed: 6.0.100-preview.4.21255.9 [C:\Program Files\dotnet\sdk] 6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk] 6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0-preview.7.21378.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0-preview.5.21301.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0-preview.7.21377.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.0-preview.5.21301.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0-preview.7.21378.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]


- visual studio 2022 preview 3
javiercn commented 3 years ago

@timeshift92 thanks for contacting us.

Are you running the template from the command-line or from an IDE?

We made significant changes to static web assets in preview7 and we are still working with the docker folks to update the IDE support for static web assets.

timeshift92 commented 3 years ago

i'm running the template from IDE, i dont made significant changes to static web asstes in preview7, i use default static files, i still running project, press f5

javiercn commented 3 years ago

@timeshift92 We are not saying that you did, we are saying that we did, and that we are yet to update our docker tooling to support it properly.

In other words, this issue is known and we are working to fix it in future versions of Visual Studio.

timeshift92 commented 3 years ago

aa understood, thanks

timeshift92 commented 3 years ago

then should I close the issue?

javiercn commented 3 years ago

@timeshift92 No, don't worry. We can keep this issue to track when the fix is available.

famda commented 3 years ago

This happens to me too. Debug mode throws the exception but in release mode is working fine. Created new project blazor wasm (hosted), added the default dockerfile.

javiercn commented 3 years ago

Likely because release does a publish or similar, VS runs Docker in an special mode where it attaches to a running container and "fixes stuff around". As mentioned, we are working with the right folks to address this.

leo-costa commented 3 years ago

@javiercn A basic .net 5 blazor server template created from vs 2019 16.11 and then change csproj from .net5.0 to net6.0 is causing this exception. This happens if you use Kestrel, IIS and WSL.

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area:  }.
         at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DynamicPageEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates) in Microsoft.AspNetCore.Mvc.RazorPages.dll:token 0x6000278+0x254
         at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet) in Microsoft.AspNetCore.Routing.dll:token 0x600033a+0x90
         at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask) in Microsoft.AspNetCore.Routing.dll:token 0x60000ba+0x65
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) in Microsoft.AspNetCore.Diagnostics.dll:token 0x60000aa+0x82

If you also update the Dockerfile from 5.0 to 6.0 and try to run from a container you get this exception.

Unhandled exception. System.ArgumentException: The path must be absolute. (Parameter 'root')
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) in Microsoft.Extensions.FileProviders.Physical.dll:token 0x600001b+0x28
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root) in Microsoft.Extensions.FileProviders.Physical.dll:token 0x600001a+0x0
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__2_1(String contentRoot) in Microsoft.AspNetCore.Hosting.dll:token 0x6000304+0x0
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.ManifestStaticWebAssetFileProvider..ctor(StaticWebAssetManifest manifest, Func`2 fileProviderFactory) in Microsoft.AspNetCore.Hosting.dll:token 0x60001bc+0x1d
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest, Boolean isJson) in Microsoft.AspNetCore.Hosting.dll:token 0x60001c5+0x22
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration) in Microsoft.AspNetCore.Hosting.dll:token 0x60001c4+0x19
   at Microsoft.AspNetCore.WebHost.<>c.<ConfigureWebDefaults>b__9_0(WebHostBuilderContext ctx, IConfigurationBuilder cb) in Microsoft.AspNetCore.dll:token 0x6000086+0xd
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass9_0.<ConfigureAppConfiguration>b__0(HostBuilderContext context, IConfigurationBuilder builder) in Microsoft.AspNetCore.Hosting.dll:token 0x6000208+0x7
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration() in Microsoft.Extensions.Hosting.dll:token 0x6000038+0x38
   at Microsoft.Extensions.Hosting.HostBuilder.Build() in Microsoft.Extensions.Hosting.dll:token 0x6000032+0x58

Interesting enough dotnet watch works even on WSL.

javiercn commented 3 years ago

@leo-costa the container issue is well-known and we are working to address it with the tooling folks.

The .net5.0 to net6.0 is new to me, however I would suggest you follow the migration steps we have in the docs. I'm not sure switching TFMs will just work.

Would you mind filing a separate issue with the details on the first issue you are encountering? Otherwise it will get lost

leo-costa commented 3 years ago

@javiercn Sure. I'll check to see if there are any other steps to migrate before filling it.

Ellested commented 3 years ago

I have the same problem testing directly on a linux host.

Host (useful for support): Version: 5.0.9 Commit: 208e377a53

.NET SDKs installed: No SDKs were found.

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.9 [/home/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.9 [/home/dotnet/shared/Microsoft.NETCore.App]


Unhandled exception. System.ArgumentException: The path must be absolute. (Parameter 'root')
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsFileProvider..ctor(String pathPrefix, String contentRoot)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__2_0(ContentRootMapping cr)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.OfTypeIterator[TResult](IEnumerable source)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)
   at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c.<UseStaticWebAssets>b__11_0(WebHostBuilderContext context, IConfigurationBuilder configBuilder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass9_0.<ConfigureAppConfiguration>b__0(HostBuilderContext context, IConfigurationBuilder builder)
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()

UPDATE: Same on Ubuntu and Alpine

mkArtakMSFT commented 3 years ago

This has been fixed in the upcoming rc2 release.

ProgrammerAL commented 2 years ago

Hi, not sure if this is the right place to put this or if I should make a new issue. But I'm seeing this same issue with .NET 6 RC 2 when running a new application through Docker Compose.

Repro Steps:

I'm running Visual Studio 17.0.0 RC2 and .NET 6.0.0-rc.2.21480.5.

I assume it an issue in other project types too, but I only checked Blazor Server.

Here's my output from dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21505.57
 Commit:    ab39070116

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\

Host (useful for support):
  Version: 6.0.0-rc.2.21480.5
  Commit:  6b11d64e7e

.NET SDKs installed:
  3.1.414 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
sloscialo commented 2 years ago

I'm getting the same error. Just the default template for an ASP.Net Core Web app.

Visual Studio 17.0.0 Preview 6.0

.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.2.21505.57
 Commit:    ab39070116

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\

Host (useful for support):
  Version: 6.0.0-rc.2.21480.5
  Commit:  6b11d64e7e

.NET SDKs installed:
  3.1.414 [C:\Program Files\dotnet\sdk]
  5.0.203 [C:\Program Files\dotnet\sdk]
  5.0.208 [C:\Program Files\dotnet\sdk]
  5.0.302 [C:\Program Files\dotnet\sdk]
  5.0.401 [C:\Program Files\dotnet\sdk]
  5.0.402 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
  6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21480.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
cetindogu commented 2 years ago

same error, everything work well on windows, not working on linux image

jzs11 commented 2 years ago

Same here, facing the same issue run Linux docker container. I am using Microsoft Visual Studio Professional 2022 Preview (64-bit) Version 17.0.0 Preview 7.0

juanchavezlive commented 2 years ago

Same problem here.

Visual Studio Version 17.0.0 Preview 7.0 .NET 6.0.0-rc.2

abul-hasan-lakhani commented 2 years ago

Still present in VS 2022 Preview 7 .Net 6 RC 2

SteeveGL commented 2 years ago

I can reproduce in .Net 5. regression? :S

VS 2019 16.11.5

.NET SDK (reflecting any global.json):
 Version:   5.0.402
 Commit:    e9d3381880

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.402\

Host (useful for support):
  Version: 5.0.11
  Commit:  f431858f8b

.NET SDKs installed:
  2.1.524 [C:\Program Files\dotnet\sdk]
  5.0.302 [C:\Program Files\dotnet\sdk]
  5.0.402 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Edit Fixed with:

For folks using docker-compose, there's a separate docker-compose issue that we are fixing in VS. See #37876 for details on how to deal with it.

For other folks, if your issue is not about docker compose, please file a separate issue so that we can track the issue properly.

raffaeler commented 2 years ago

I still get this in version 6.0.100-rc.2.21505.57 on linux-arm when the ASP.NET hoting environment is Development. It works if it runs in Production

markheath commented 2 years ago

I'm seeing this too with 6.0.100-rc.2.21505.57 and VS2022 17.0.0 Preview 7.0

javiercn commented 2 years ago

For folks using docker-compose, there's a separate docker-compose issue that we are fixing in VS. See https://github.com/dotnet/aspnetcore/issues/37876 for details on how to deal with it.

For other folks, if your issue is not about docker compose, please file a separate issue so that we can track the issue properly.

raffaeler commented 2 years ago

@javiercn I already did it: