Static file "static" configuration
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
I expected to be able to configure static file wwwroot directory (_site in my case) by setting Environment.ContentRootPath/WebRootPath but I was only able to do it with a file provider (physical).
### Expected Behavior
```
using var app = WebApplication.Create();
app.Urls.Add($"http://localhost:4200"); // todo: config
// works but not desired:
// app.Environment.WebRootFileProvider = new PhysicalFileProvider(configuration.Output.Location);
// desired but does not work
app.Environment.ContentRootPath = "/opt/foo/test";
app.Environment.WebRootPath = "_site"; // also tested an absolute path
app.UseDefaultFiles();
app.UseStaticFiles();
logger.LogInformation("Started server on {Urls}", app.Urls);
app.Run();
```
What's weird is that it logs the right folder but that it does not exist (whereas I can always "ls" it)
### Steps To Reproduce
Just create a minimal aspnet.core project with ^^ code
### Exceptions (if any)
-
### .NET Version
8.0.107
### Anything else?
```
SDK .NET :
Version: 8.0.107
Commit: 1bdaef7265
Workload version: 8.0.100-manifests.43c23f91
Environnement d'exécution :
OS Name: zorin
OS Version: 17
OS Platform: Linux
RID: ubuntu.22.04-x64
Base Path: /usr/lib/dotnet/sdk/8.0.107/
Charges de travail .NET installées :
Workload version: 8.0.100-manifests.43c23f91
Il n'y a aucune charge de travail installée à afficher.
Host:
Version: 8.0.7
Architecture: x64
Commit: 2aade6beb0
.NET SDKs installed:
8.0.107 [/usr/lib/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.7 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.7 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
/opt/rmannibucau/dev/SBSharp/global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
```
Contributor guide
Assessment
This issue has not been assessed yet.