Refactored plugin loading. Added project settings for packing
This commit is contained in:
@@ -5,16 +5,19 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<IsPackable>true</IsPackable>
|
||||
<Version>2.1.0</Version>
|
||||
<Title>MoonlightServers.ApiServer</Title>
|
||||
<PackageTags>apiserver</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moonlight.ApiServer" Version="2.1.0"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11"/>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.15"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj" />
|
||||
<ProjectReference Include="..\MoonlightServers.DaemonShared\MoonlightServers.DaemonShared.csproj"/>
|
||||
<ProjectReference Include="..\MoonlightServers.Frontend\MoonlightServers.Frontend.csproj"/>
|
||||
<ProjectReference Include="..\MoonlightServers.Shared\MoonlightServers.Shared.csproj"/>
|
||||
</ItemGroup>
|
||||
@@ -22,8 +25,24 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="Database\Migrations\"/>
|
||||
<Folder Include="Http\Middleware\"/>
|
||||
<Folder Include="Implementations\" />
|
||||
<Folder Include="Implementations\"/>
|
||||
<Folder Include="Interfaces\"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="**\*.cs" Exclude="storage\**\*;bin\**\*;obj\**\*">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>src</PackagePath>
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="**\*.razor" Exclude="storage\**\*;bin\**\*;obj\**\*">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>src</PackagePath>
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Compile Remove="storage\**\*"/>
|
||||
<Content Remove="storage\**\*"/>
|
||||
<None Remove="storage\**\*"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Moonlight.ApiServer;
|
||||
using Moonlight.ApiServer.Models;
|
||||
using MoonlightServers.ApiServer.Startup;
|
||||
|
||||
// Development Server Startup
|
||||
|
||||
@@ -28,8 +29,6 @@ pluginManifest.Assemblies.Clear();
|
||||
|
||||
#endregion
|
||||
|
||||
await startup.Run(
|
||||
args,
|
||||
[typeof(Program).Assembly],
|
||||
[pluginManifest]
|
||||
);
|
||||
await startup.Run(args, [
|
||||
new PluginStartup()
|
||||
]);
|
||||
@@ -1,30 +1,49 @@
|
||||
using MoonCore.Extensions;
|
||||
using Moonlight.ApiServer.Interfaces.Startup;
|
||||
using Moonlight.ApiServer.Configuration;
|
||||
using Moonlight.ApiServer.Models;
|
||||
using Moonlight.ApiServer.Plugins;
|
||||
using MoonlightServers.ApiServer.Database;
|
||||
using MoonlightServers.ApiServer.Helpers;
|
||||
|
||||
namespace MoonlightServers.ApiServer.Startup;
|
||||
|
||||
[PluginStartup]
|
||||
public class PluginStartup : IPluginStartup
|
||||
{
|
||||
public Task BuildApplication(IHostApplicationBuilder builder)
|
||||
public Task BuildApplication(IServiceProvider serviceProvider, IHostApplicationBuilder builder)
|
||||
{
|
||||
// Scan the current plugin assembly for di services
|
||||
builder.Services.AutoAddServices<PluginStartup>();
|
||||
|
||||
builder.Services.AddDbContext<ServersDataContext>();
|
||||
|
||||
|
||||
// Configure authentication for the remote endpoints
|
||||
builder.Services
|
||||
.AddAuthentication()
|
||||
.AddScheme<NodeAuthOptions, NodeAuthScheme>("nodeAuthentication", null);
|
||||
|
||||
|
||||
var configuration = serviceProvider.GetRequiredService<AppConfiguration>();
|
||||
|
||||
if (configuration.Client.Enable)
|
||||
{
|
||||
builder.Services.AddSingleton(new FrontendConfigurationOption()
|
||||
{
|
||||
Scripts =
|
||||
[
|
||||
"js/XtermBlazor.min.js",
|
||||
"js/addon-fit.js",
|
||||
"js/moonlightServers.js"
|
||||
],
|
||||
Styles = ["css/XtermBlazor.min.css"]
|
||||
});
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ConfigureApplication(IApplicationBuilder app)
|
||||
=> Task.CompletedTask;
|
||||
public Task ConfigureApplication(IServiceProvider serviceProvider, IApplicationBuilder app)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
public Task ConfigureEndpoints(IEndpointRouteBuilder routeBuilder)
|
||||
public Task ConfigureEndpoints(IServiceProvider serviceProvider, IEndpointRouteBuilder routeBuilder)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user