Skip to content

Commit

Permalink
Static ww wroot/ra (dotnet#2)
Browse files Browse the repository at this point in the history
* static assets problem when changing wwwroot

* static assets problem when changing wwwroot
  • Loading branch information
Rick-Anderson authored Mar 31, 2022
1 parent d5cf0e4 commit 7e5a495
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 0 deletions.
21 changes: 21 additions & 0 deletions fundamentals/static-files/WebRoot/Program.cs
Original file line number Diff line number Diff line change
@@ -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();
30 changes: 30 additions & 0 deletions fundamentals/static-files/WebRoot/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
20 changes: 20 additions & 0 deletions fundamentals/static-files/WebRoot/WebRoot.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Content Remove="wwwroot\**" />
</ItemGroup>

<ItemGroup>
<Content Include="wwwroot-custom\Index.html">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions fundamentals/static-files/WebRoot/WebRoot.sln
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions fundamentals/static-files/WebRoot/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
9 changes: 9 additions & 0 deletions fundamentals/static-files/WebRoot/wwwroot-custom/Index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>custom</title>
</head>
<body>
<h1>From custom wwwroot</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions fundamentals/static-files/WebRoot/wwwroot/Index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>wwwroot</title>
</head>
<body>
<h1>From wwwroot</h1>
</body>
</html>

0 comments on commit 7e5a495

Please sign in to comment.