fix #125 System.InvalidOperationException: 'Could not load the embedded file manifest #125

This commit is contained in:
MysticBoy
2022-04-24 13:56:54 +08:00
parent 0c61a1b753
commit 59e7d029c4
29 changed files with 63 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Quartz;
@@ -44,7 +45,7 @@ namespace Microsoft.AspNetCore.Builder
[Obsolete("We recommend UseSilkierQuartz")]
public static IApplicationBuilder UseQuartzmin(this IApplicationBuilder app, Action<Services> configure = null)
=> app.UseSilkierQuartz(configure);
=> app.UseSilkierQuartz(configure: configure);
/// <summary>
/// Use SilkierQuartz and automatically discover IJob subclasses with SilkierQuartzAttribute
@@ -52,8 +53,7 @@ namespace Microsoft.AspNetCore.Builder
/// <param name="app"></param>
/// <param name="configure"></param>
public static IApplicationBuilder UseSilkierQuartz(
this IApplicationBuilder app,
Action<Services> configure = null)
this IApplicationBuilder app ,Action<Services> configure = null)
{
var options = app.ApplicationServices
.GetService<SilkierQuartzOptions>() ?? throw new ArgumentNullException(nameof(SilkierQuartzOptions));
@@ -140,11 +140,12 @@ namespace Microsoft.AspNetCore.Builder
private static void UseFileServer(this IApplicationBuilder app, SilkierQuartzOptions options)
{
IFileProvider fs;
if (string.IsNullOrEmpty(options.ContentRootDirectory))
fs = new ManifestEmbeddedFileProvider(Assembly.GetExecutingAssembly(), "Content");
else
fs = new PhysicalFileProvider(options.ContentRootDirectory);
var manifestEmbeddedProvider =
new EmbeddedFileProvider(typeof(SilkierQuartzOptions).Assembly);
fs = new EmbeddedFileProvider(typeof(SilkierQuartzOptions).Assembly, "SilkierQuartz.Content");
var fsOptions = new FileServerOptions()
{
RequestPath = new PathString($"{options.VirtualPathRoot}/Content"),

View File

@@ -1,8 +1,8 @@
https://cdn.jsdelivr.net/npm/semantic-ui@2.3.3/dist/semantic.min.css
https://cdn.rawgit.com/mdehoog/Semantic-UI-Calendar/76959c6f7d33a527b49be76789e984a0a407350b/dist/calendar.min.css
https://cdn.jsdelivr.net/npm/semanticui@2.3.3/dist/semantic.min.css
https://cdn.rawgit.com/mdehoog/semanticui-Calendar/76959c6f7d33a527b49be76789e984a0a407350b/dist/calendar.min.css
https://code.jquery.com/jquery-3.3.1.min.js"
https://cdn.jsdelivr.net/npm/semantic-ui@2.3.3/dist/semantic.min.js
https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.0/components/state.min.js
https://cdn.jsdelivr.net/npm/semanticui@2.3.3/dist/semantic.min.js
https://cdnjs.cloudflare.com/ajax/libs/semanticui/2.3.0/components/state.min.js
https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js
https://cdn.rawgit.com/mdehoog/Semantic-UI-Calendar/76959c6f7d33a527b49be76789e984a0a407350b/dist/calendar.min.js
https://cdn.rawgit.com/mdehoog/semanticui-Calendar/76959c6f7d33a527b49be76789e984a0a407350b/dist/calendar.min.js

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -29,10 +29,37 @@
<PackageIcon>logo.png</PackageIcon>
<IsPackable>true</IsPackable>
</PropertyGroup>
<PropertyGroup>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
<PropertyGroup>
<DefineConstants></DefineConstants>
<OutputType>Library</OutputType>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
<Optimize>True</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.1|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net5.0|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Quartz.Plugins.RecentHistory\Quartz.Plugins.RecentHistory.csproj" />

View File

@@ -74,17 +74,8 @@ namespace SilkierQuartz
StandardTypes.Add(new StringHandler() { Name = "MultilineString", DisplayName = "String (Multiline)", IsMultiline = true });
}
#if DEBUG
public string SitePhysicalDirectory { get; set; }
internal string ContentRootDirectory =>
string.IsNullOrEmpty(SitePhysicalDirectory) ? null : Path.Combine(SitePhysicalDirectory, "Content");
internal string ViewsRootDirectory =>
string.IsNullOrEmpty(SitePhysicalDirectory) ? null : Path.Combine(SitePhysicalDirectory, "Views");
#else
internal string ContentRootDirectory => null;
internal string ViewsRootDirectory => null;
#endif
}
}

View File

@@ -1,4 +1,6 @@
using HandlebarsDotNet;
using Microsoft.Extensions.FileProviders;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
@@ -10,7 +12,6 @@ namespace SilkierQuartz
public static ViewEngineFileSystem Create(SilkierQuartzOptions options)
{
ViewEngineFileSystem fs;
if (string.IsNullOrEmpty(options.ViewsRootDirectory))
{
fs = new EmbeddedFileSystem();
@@ -55,18 +56,19 @@ namespace SilkierQuartz
private class EmbeddedFileSystem : ViewEngineFileSystem
{
private EmbeddedFileProvider fs = new EmbeddedFileProvider(Assembly.GetExecutingAssembly(), "SilkierQuartz.Views");
public override string GetFileContent(string filename)
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetFullPath(filename)))
string result = string.Empty;
var fi = fs.GetFileInfo(GetFullPath(filename));
using (var stream =fi.CreateReadStream())
{
if (stream == null)
return null;
using (var reader = new StreamReader(stream, Encoding.UTF8))
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
result = reader.ReadToEnd();
}
}
return result;
}
protected override string CombinePath(string dir, string otherFileName)
@@ -76,13 +78,13 @@ namespace SilkierQuartz
public override bool FileExists(string filePath)
{
return Assembly.GetExecutingAssembly().GetManifestResourceInfo(GetFullPath(filePath)) != null;
return fs.GetFileInfo(GetFullPath(filePath)).Exists;
}
string GetFullPath(string filePath)
{
return Path.Combine(nameof(SilkierQuartz) + ".Views", filePath.Replace("partials/", "Partials/")).Replace('/', '.').Replace('\\', '.');
return filePath.Replace("partials/", "Partials/").Replace('/', Path.DirectorySeparatorChar);
}
}
}

View File

@@ -9,7 +9,7 @@
<title>Error</title>
<link rel="stylesheet" href="Content/Lib/semantic-ui/semantic.min.css" type="text/css">
<link rel="stylesheet" href="Content/Lib/semanticui/semantic.min.css" type="text/css">
<link rel="stylesheet" href="Content/Fonts/Lato.css" type="text/css" />
<style type="text/css">

View File

@@ -17,17 +17,17 @@
<link rel="icon" type="image/png" sizes="192x192" href="Content/Images/favicons/favicon-192.png">
<link rel="icon" type="image/png" sizes="256x256" href="Content/Images/favicons/favicon-256.png">
<link rel="stylesheet" href="Content/Lib/semantic-ui/semantic.min.css" type="text/css">
<link rel="stylesheet" href="Content/Lib/semantic-ui/calendar.min.css" type="text/css" />
<link rel="stylesheet" href="Content/Lib/semanticui/semantic.min.css" type="text/css">
<link rel="stylesheet" href="Content/Lib/semanticui/calendar.min.css" type="text/css" />
<link rel="stylesheet" href="Content/Fonts/Lato.css" type="text/css" />
<link rel="stylesheet" href="Content/Site.css" type="text/css" />
<script src="Content/Lib/jquery-3.3.1.min.js"></script>
<script src="Content/Lib/moment.min.js"></script>
<script src="Content/Lib/FileSaver.js"></script>
<script src="Content/Lib/semantic-ui/semantic.min.js"></script>
<script src="Content/Lib/semantic-ui/state.min.js"></script>
<script src="Content/Lib/semantic-ui/calendar.min.js"></script>
<script src="Content/Lib/semanticui/semantic.min.js"></script>
<script src="Content/Lib/semanticui/state.min.js"></script>
<script src="Content/Lib/semanticui/calendar.min.js"></script>
<script src="Content/Scripts/global.js"></script>
</head>