From 7e5a495c29006dfbbeb39e141f5deaf8ca20c87b Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 30 Mar 2022 16:01:49 -1000 Subject: [PATCH] Static ww wroot/ra (#2) * static assets problem when changing wwwroot * static assets problem when changing wwwroot --- fundamentals/static-files/WebRoot/Program.cs | 21 +++++++++++++ .../WebRoot/Properties/launchSettings.json | 30 +++++++++++++++++++ .../static-files/WebRoot/WebRoot.csproj | 20 +++++++++++++ fundamentals/static-files/WebRoot/WebRoot.sln | 25 ++++++++++++++++ .../WebRoot/appsettings.Development.json | 8 +++++ .../static-files/WebRoot/appsettings.json | 9 ++++++ .../WebRoot/wwwroot-custom/Index.html | 9 ++++++ .../static-files/WebRoot/wwwroot/Index.html | 9 ++++++ 8 files changed, 131 insertions(+) create mode 100644 fundamentals/static-files/WebRoot/Program.cs create mode 100644 fundamentals/static-files/WebRoot/Properties/launchSettings.json create mode 100644 fundamentals/static-files/WebRoot/WebRoot.csproj create mode 100644 fundamentals/static-files/WebRoot/WebRoot.sln create mode 100644 fundamentals/static-files/WebRoot/appsettings.Development.json create mode 100644 fundamentals/static-files/WebRoot/appsettings.json create mode 100644 fundamentals/static-files/WebRoot/wwwroot-custom/Index.html create mode 100644 fundamentals/static-files/WebRoot/wwwroot/Index.html diff --git a/fundamentals/static-files/WebRoot/Program.cs b/fundamentals/static-files/WebRoot/Program.cs new file mode 100644 index 000000000000..9877e54dd8e2 --- /dev/null +++ b/fundamentals/static-files/WebRoot/Program.cs @@ -0,0 +1,21 @@ +var builder = WebApplication.CreateBuilder(new WebApplicationOptions +{ + Args = args, + // Examine Hosting environment: logging value + EnvironmentName = Environments.Staging, + // Look for static files in "wwwroot-custom" + WebRootPath = "wwwroot-custom" +}); + +var app = builder.Build(); + +app.Logger.LogInformation("ASPNETCORE_ENVIRONMENT: {env}", + Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); + +app.Logger.LogInformation("app.Environment.IsDevelopment(): {env}", + app.Environment.IsDevelopment().ToString()); + +app.UseDefaultFiles(); +app.UseStaticFiles(); + +app.Run(); diff --git a/fundamentals/static-files/WebRoot/Properties/launchSettings.json b/fundamentals/static-files/WebRoot/Properties/launchSettings.json new file mode 100644 index 000000000000..6cbc47646ff3 --- /dev/null +++ b/fundamentals/static-files/WebRoot/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:2483", + "sslPort": 44302 + } + }, + "profiles": { + "WebRoot": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7006;http://localhost:5006", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + //,"ASPNETCORE_ENVIRONMENT": "Production" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + //,"ASPNETCORE_ENVIRONMENT": "Production" + } + } + } +} diff --git a/fundamentals/static-files/WebRoot/WebRoot.csproj b/fundamentals/static-files/WebRoot/WebRoot.csproj new file mode 100644 index 000000000000..cae4bd2ba86e --- /dev/null +++ b/fundamentals/static-files/WebRoot/WebRoot.csproj @@ -0,0 +1,20 @@ + + + + net6.0 + enable + enable + + + + + + + + + true + PreserveNewest + + + + diff --git a/fundamentals/static-files/WebRoot/WebRoot.sln b/fundamentals/static-files/WebRoot/WebRoot.sln new file mode 100644 index 000000000000..93ed95c2262e --- /dev/null +++ b/fundamentals/static-files/WebRoot/WebRoot.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32228.430 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebRoot", "WebRoot.csproj", "{E2E98526-6D6C-4A2A-861A-93F288983C4F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E2E98526-6D6C-4A2A-861A-93F288983C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E2E98526-6D6C-4A2A-861A-93F288983C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E2E98526-6D6C-4A2A-861A-93F288983C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E2E98526-6D6C-4A2A-861A-93F288983C4F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EFCDA9A5-B0F5-49E0-B732-19C61C4BFC13} + EndGlobalSection +EndGlobal diff --git a/fundamentals/static-files/WebRoot/appsettings.Development.json b/fundamentals/static-files/WebRoot/appsettings.Development.json new file mode 100644 index 000000000000..0c208ae9181e --- /dev/null +++ b/fundamentals/static-files/WebRoot/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/fundamentals/static-files/WebRoot/appsettings.json b/fundamentals/static-files/WebRoot/appsettings.json new file mode 100644 index 000000000000..10f68b8c8b4f --- /dev/null +++ b/fundamentals/static-files/WebRoot/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/fundamentals/static-files/WebRoot/wwwroot-custom/Index.html b/fundamentals/static-files/WebRoot/wwwroot-custom/Index.html new file mode 100644 index 000000000000..4f0a0f6c355c --- /dev/null +++ b/fundamentals/static-files/WebRoot/wwwroot-custom/Index.html @@ -0,0 +1,9 @@ + + + + custom + + +

From custom wwwroot

+ + \ No newline at end of file diff --git a/fundamentals/static-files/WebRoot/wwwroot/Index.html b/fundamentals/static-files/WebRoot/wwwroot/Index.html new file mode 100644 index 000000000000..5c07c2ed9ad5 --- /dev/null +++ b/fundamentals/static-files/WebRoot/wwwroot/Index.html @@ -0,0 +1,9 @@ + + + + wwwroot + + +

From wwwroot

+ + \ No newline at end of file