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.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.IO;
using System;
using System.Reflection;
namespace Props
{
@ -20,7 +17,7 @@ namespace Props
Host.CreateDefaultBuilder(args)
.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">
<!-- 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 -->
<!-- Single file docs: https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file/overview -->
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<SelfContained>true</SelfContained>
<PublishTrimmed>false</PublishTrimmed>
<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>
</PropertyGroup>
@ -51,39 +51,20 @@
</ItemGroup>
</Target>
<!-- For embedding content into single file. -->
<PropertyGroup>
<!-- See https://github.com/MicrosoftDocs/visualstudio-docs/issues/2257 -->
<EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>
<ItemGroup>
<!-- See https://stackoverflow.com/questions/46983930/what-content-items-does-enabledefaultcontentitems-enable -->
<!-- See https://github.com/SteveSandersonMS/WebWindow/issues/41#issuecomment-590122872 -->
<!-- See https://github.com/dotnet/sdk/blob/0e0829e55c398752ddda5cc247ef3ad722a019c2/src/WebSdk/Worker/Targets/Microsoft.NET.Sdk.Worker.props -->
<!-- See https://github.com/dotnet/sdk/blob/a30e465a2e2ea4e2550f319a2dc088daaafe5649/src/RazorSdk/Sdk/Sdk.Razor.StaticAssets.ProjectSystem.props -->
<!-- We disabled default content items to change some attributes, we will also add the rest here. -->
<Content Update="wwwroot\**" ExcludeFromSingleFile="false" CopyToOutputDirectory="PreserveNewest" />
<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\**" />
<Content Remove="wwwroot\**" />
<None Include="wwwroot\**" ExcludeFromSingleFile="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<!-- Ignore client-side asset compilation configuration. -->
<Content Remove="package.json" />
<Content Remove="package-lock.json" />
</ItemGroup>
<!-- Modules for all the shops. -->
<ItemGroup>
<None Update="shops\**\*" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
<None Update="shops\**\*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
</ItemGroup>
<!-- Watch configurations. -->
@ -113,6 +94,4 @@
</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." />
</Target>
</Project>

View File

@ -2,6 +2,7 @@ namespace Props.Services.Content
{
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; }
}
}

View File

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