wwwroot is now extracted on run.

This commit is contained in:
Harrison Deng 2022-04-24 22:20:35 -05:00
parent 8abd75506c
commit f8ad3b2970
4 changed files with 17 additions and 39 deletions

View File

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using System.IO;
using System;
using System.Reflection;
namespace Props namespace Props
{ {
@ -20,7 +17,7 @@ namespace Props
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseWebRoot(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wwwroot/")).UseStartup<Startup>();
}); });
} }
} }

View File

@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<!-- https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props for more information. --> <!-- https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props for more information. -->
<!-- TODO: Embed wwwroot. -->
<!-- Publish arguments: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish --> <!-- Publish arguments: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish -->
<!-- Single file docs: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file/overview --> <!-- Single file docs: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file/overview -->
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile> <PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<SelfContained>true</SelfContained> <SelfContained>true</SelfContained>
<PublishTrimmed>false</PublishTrimmed> <PublishTrimmed>false</PublishTrimmed>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier> <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> <PublishReadyToRun>true</PublishReadyToRun>
<!-- <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> -->
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<UserSecretsId>aspnet-Props-20A2A991-EC61-4C06-91D2-953482026A7B</UserSecretsId> <UserSecretsId>aspnet-Props-20A2A991-EC61-4C06-91D2-953482026A7B</UserSecretsId>
</PropertyGroup> </PropertyGroup>
@ -51,39 +51,20 @@
</ItemGroup> </ItemGroup>
</Target> </Target>
<!-- For embedding content into single file. --> <!-- For embedding content into single file. -->
<PropertyGroup>
<!-- See https://github.com/MicrosoftDocs/visualstudio-docs/issues/2257 -->
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- See https://stackoverflow.com/questions/46983930/what-content-items-does-enabledefaultcontentitems-enable --> <Content Remove="wwwroot\**" />
<!-- See https://github.com/SteveSandersonMS/WebWindow/issues/41#issuecomment-590122872 --> <None Include="wwwroot\**" ExcludeFromSingleFile="false">
<!-- See https://github.com/dotnet/sdk/blob/0e0829e55c398752ddda5cc247ef3ad722a019c2/src/WebSdk/Worker/Targets/Microsoft.NET.Sdk.Worker.props --> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- See https://github.com/dotnet/sdk/blob/a30e465a2e2ea4e2550f319a2dc088daaafe5649/src/RazorSdk/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props --> </None>
<!-- We disabled default content items to change some attributes, we will also add the rest here. --> <!-- Ignore client-side asset compilation configuration. -->
<Content Update="wwwroot\**" ExcludeFromSingleFile="false" CopyToOutputDirectory="PreserveNewest" /> <Content Remove="package.json" />
<Content Remove="package-lock.json" />
<Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" />
<Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'" />
<!-- When ExcludeConfigFilesFromBuildOutput is set, do not copy .,config, .json files to the build output directory. -->
<Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'=='true'" />
<Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" Condition="'$(ExcludeConfigFilesFromBuildOutput)'=='true'" />
<!-- Set CopyToOutputDirectory and CopyToPublishDirectory to Never for items under AppDesignerFolder ("Properties", by default) to avoid publishing launchSettings.json -->
<Content Update="$(AppDesignerFolder)\**" CopyToOutputDirectory="Never" CopyToPublishDirectory="Never" Condition="'$(AppDesignerFolder)' != ''" />
<!-- Remove Content items from other item types -->
<None Remove="wwwroot\**;**\*.json;**\*.config" />
<Compile Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
</ItemGroup> </ItemGroup>
<!-- Modules for all the shops. --> <!-- Modules for all the shops. -->
<ItemGroup> <ItemGroup>
<None Update="shops\**\*" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" /> <None Update="shops\**\*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
</ItemGroup> </ItemGroup>
<!-- Watch configurations. --> <!-- Watch configurations. -->
@ -113,6 +94,4 @@
</Exec> </Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="There was an issue attempting to build the static assets. To continue, fix client-side asset errors and try again." /> <Error Condition="'$(ErrorCode)' != '0'" Text="There was an issue attempting to build the static assets. To continue, fix client-side asset errors and try again." />
</Target> </Target>
</Project> </Project>

View File

@ -2,6 +2,7 @@ namespace Props.Services.Content
{ {
public interface ITextualManager<out TModel> public interface ITextualManager<out TModel>
{ {
// TODO: Replace this system with globalization and localization. See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-6.0
dynamic Json { get; } dynamic Json { get; }
} }
} }

View File

@ -8,6 +8,7 @@ using Props.Data;
using Props.Models.User; using Props.Models.User;
using Props.Services.Content; using Props.Services.Content;
using Props.Services.Modules; using Props.Services.Modules;
using System;
namespace Props namespace Props
{ {