From 99cec068d091dfb5d86be5167849e30669984ba6 Mon Sep 17 00:00:00 2001 From: Mikko Uuksulainen Date: Mon, 4 Jan 2021 13:05:28 +0200 Subject: [PATCH 1/3] Update to target multiple frameworks (netcoreapp3.1 and net5.0) --- global.json | 2 +- .../Weikio.PluginFramework.AspNetCore.csproj | 4 ++-- .../Weikio.PluginFramework.Catalogs.NuGet.csproj | 4 ++-- .../Weikio.PluginFramework.Catalogs.Roslyn.csproj | 4 ++-- .../Weikio.PluginFramework.Configuration.csproj | 2 +- src/Weikio.PluginFramework/Weikio.PluginFramework.csproj | 4 ++-- .../Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj | 2 +- .../Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj | 4 ++-- .../Weikio.PluginFramework.Tests.csproj | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/global.json b/global.json index 45116e5..526044f 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.101", + "version": "5.0.101", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/src/Weikio.PluginFramework.AspNetCore/Weikio.PluginFramework.AspNetCore.csproj b/src/Weikio.PluginFramework.AspNetCore/Weikio.PluginFramework.AspNetCore.csproj index b127aef..f9a83d4 100644 --- a/src/Weikio.PluginFramework.AspNetCore/Weikio.PluginFramework.AspNetCore.csproj +++ b/src/Weikio.PluginFramework.AspNetCore/Weikio.PluginFramework.AspNetCore.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 true true Plugin Framework for ASP.NET Core. diff --git a/src/Weikio.PluginFramework.Catalogs.NuGet/Weikio.PluginFramework.Catalogs.NuGet.csproj b/src/Weikio.PluginFramework.Catalogs.NuGet/Weikio.PluginFramework.Catalogs.NuGet.csproj index 22a0dbd..8848590 100644 --- a/src/Weikio.PluginFramework.Catalogs.NuGet/Weikio.PluginFramework.Catalogs.NuGet.csproj +++ b/src/Weikio.PluginFramework.Catalogs.NuGet/Weikio.PluginFramework.Catalogs.NuGet.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 true true NuGet catalog for Plugin Framework allows you to use NuGet packages as plugins with Plugin Framework. diff --git a/src/Weikio.PluginFramework.Catalogs.Roslyn/Weikio.PluginFramework.Catalogs.Roslyn.csproj b/src/Weikio.PluginFramework.Catalogs.Roslyn/Weikio.PluginFramework.Catalogs.Roslyn.csproj index b727390..1da0730 100644 --- a/src/Weikio.PluginFramework.Catalogs.Roslyn/Weikio.PluginFramework.Catalogs.Roslyn.csproj +++ b/src/Weikio.PluginFramework.Catalogs.Roslyn/Weikio.PluginFramework.Catalogs.Roslyn.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 true true Roslyn catalog for Plugin Framework allows you to use Roslyn scripts as plugins with Plugin Framework. diff --git a/src/Weikio.PluginFramework.Configuration/Weikio.PluginFramework.Configuration.csproj b/src/Weikio.PluginFramework.Configuration/Weikio.PluginFramework.Configuration.csproj index 68d12ab..47fb5f5 100644 --- a/src/Weikio.PluginFramework.Configuration/Weikio.PluginFramework.Configuration.csproj +++ b/src/Weikio.PluginFramework.Configuration/Weikio.PluginFramework.Configuration.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + netcoreapp3.1;net5.0 enable true true diff --git a/src/Weikio.PluginFramework/Weikio.PluginFramework.csproj b/src/Weikio.PluginFramework/Weikio.PluginFramework.csproj index fb83542..392f4cf 100644 --- a/src/Weikio.PluginFramework/Weikio.PluginFramework.csproj +++ b/src/Weikio.PluginFramework/Weikio.PluginFramework.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 true true Plugin Framework is a powerful plugin platform for your .NET Core applications. diff --git a/tests/integration/Weikio.PluginFramework.Catalogs.NuGet.Tests/Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj b/tests/integration/Weikio.PluginFramework.Catalogs.NuGet.Tests/Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj index cc93c63..c837532 100644 --- a/tests/integration/Weikio.PluginFramework.Catalogs.NuGet.Tests/Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj +++ b/tests/integration/Weikio.PluginFramework.Catalogs.NuGet.Tests/Weikio.PluginFramework.Catalogs.NuGet.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + netcoreapp3.1;net5.0 diff --git a/tests/unit/Weikio.PluginFramework.Catalogs.Roslyn.Tests/Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj b/tests/unit/Weikio.PluginFramework.Catalogs.Roslyn.Tests/Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj index 7b98ce4..82a65f7 100644 --- a/tests/unit/Weikio.PluginFramework.Catalogs.Roslyn.Tests/Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj +++ b/tests/unit/Weikio.PluginFramework.Catalogs.Roslyn.Tests/Weikio.PluginFramework.Catalogs.Roslyn.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 diff --git a/tests/unit/Weikio.PluginFramework.Tests/Weikio.PluginFramework.Tests.csproj b/tests/unit/Weikio.PluginFramework.Tests/Weikio.PluginFramework.Tests.csproj index b63b8b7..7fa6420 100644 --- a/tests/unit/Weikio.PluginFramework.Tests/Weikio.PluginFramework.Tests.csproj +++ b/tests/unit/Weikio.PluginFramework.Tests/Weikio.PluginFramework.Tests.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;net5.0 From 2a1a9a07e1e9c9513b74583198032ace414e47b9 Mon Sep 17 00:00:00 2001 From: Mikko Uuksulainen Date: Tue, 5 Jan 2021 13:34:08 +0200 Subject: [PATCH 2/3] Add .NET 5.0 Web API sample project --- .../Controllers/CalculatorController.cs | 29 ++++++++ samples/WebAppDotNet5/Program.cs | 26 +++++++ samples/WebAppDotNet5/Startup.cs | 72 +++++++++++++++++++ samples/WebAppDotNet5/WebAppDotNet5.csproj | 19 +++++ .../appsettings.Development.json | 9 +++ samples/WebAppDotNet5/appsettings.json | 10 +++ src/PluginFramework.sln | 13 +++- 7 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 samples/WebAppDotNet5/Controllers/CalculatorController.cs create mode 100644 samples/WebAppDotNet5/Program.cs create mode 100644 samples/WebAppDotNet5/Startup.cs create mode 100644 samples/WebAppDotNet5/WebAppDotNet5.csproj create mode 100644 samples/WebAppDotNet5/appsettings.Development.json create mode 100644 samples/WebAppDotNet5/appsettings.json diff --git a/samples/WebAppDotNet5/Controllers/CalculatorController.cs b/samples/WebAppDotNet5/Controllers/CalculatorController.cs new file mode 100644 index 0000000..d14cbb9 --- /dev/null +++ b/samples/WebAppDotNet5/Controllers/CalculatorController.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Weikio.PluginFramework.Abstractions; +using Weikio.PluginFramework.Samples.Shared; + +namespace WebAppDotNet5.Controllers +{ + [ApiController] + [Route("[controller]")] + public class CalculatorController : ControllerBase + { + private readonly IEnumerable _operators; + private readonly IEnumerable _plugins; + + public CalculatorController(IEnumerable operators, IEnumerable plugins, IOperator myOperator) + { + _operators = operators; + _plugins = plugins; + } + + [HttpGet] + public string Get() + { + var pluginsList = string.Join(", ", _plugins); + + return pluginsList; + } + } +} diff --git a/samples/WebAppDotNet5/Program.cs b/samples/WebAppDotNet5/Program.cs new file mode 100644 index 0000000..dc14ca7 --- /dev/null +++ b/samples/WebAppDotNet5/Program.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace WebAppDotNet5 +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/samples/WebAppDotNet5/Startup.cs b/samples/WebAppDotNet5/Startup.cs new file mode 100644 index 0000000..045cbee --- /dev/null +++ b/samples/WebAppDotNet5/Startup.cs @@ -0,0 +1,72 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpsPolicy; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Weikio.PluginFramework.Catalogs; +using Weikio.PluginFramework.Samples.Shared; + +namespace WebAppDotNet5 +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + var folderPluginCatalog = new FolderPluginCatalog(@"..\Shared\Weikio.PluginFramework.Samples.SharedPlugins\bin\debug\netcoreapp3.1", type => + { + type.Implements(); + }); + + services.AddPluginFramework() + .AddPluginCatalog(folderPluginCatalog) + .AddPluginType(); + + // Alternatively + // services.AddPluginFramework(@"..\Shared\Weikio.PluginFramework.Samples.SharedPlugins\bin\debug\netcoreapp3.1"); + + services.AddControllers(); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAppDotNet5", Version = "v1" }); + }); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebAppDotNet5 v1")); + } + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/WebAppDotNet5/WebAppDotNet5.csproj b/samples/WebAppDotNet5/WebAppDotNet5.csproj new file mode 100644 index 0000000..2bea0b9 --- /dev/null +++ b/samples/WebAppDotNet5/WebAppDotNet5.csproj @@ -0,0 +1,19 @@ + + + + net5.0 + + + + + + + + + + + + + + + diff --git a/samples/WebAppDotNet5/appsettings.Development.json b/samples/WebAppDotNet5/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/samples/WebAppDotNet5/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/samples/WebAppDotNet5/appsettings.json b/samples/WebAppDotNet5/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/samples/WebAppDotNet5/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/src/PluginFramework.sln b/src/PluginFramework.sln index 235d067..f3d6084 100644 --- a/src/PluginFramework.sln +++ b/src/PluginFramework.sln @@ -61,11 +61,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsApp", "..\samples\W EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsPluginsLibrary", "..\samples\WinFormsPluginsLibrary\WinFormsPluginsLibrary.csproj", "{E92B0C5D-FFAC-4AB9-B069-869AEED565B0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Weikio.PluginFramework.Configuration", "Weikio.PluginFramework.Configuration\Weikio.PluginFramework.Configuration.csproj", "{882BB58E-D256-4BBF-8C5F-80C4FA39B775}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Weikio.PluginFramework.Configuration", "Weikio.PluginFramework.Configuration\Weikio.PluginFramework.Configuration.csproj", "{882BB58E-D256-4BBF-8C5F-80C4FA39B775}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppWithAppSettings", "..\samples\WebAppWithAppSettings\WebAppWithAppSettings.csproj", "{A5FAE1A5-74A0-4A83-9520-DCABF6610ADE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAppWithAppSettings", "..\samples\WebAppWithAppSettings\WebAppWithAppSettings.csproj", "{A5FAE1A5-74A0-4A83-9520-DCABF6610ADE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppPluginsLibrary", "..\samples\WebAppPluginsLibrary\WebAppPluginsLibrary.csproj", "{38CCE0F7-F998-4766-A14A-44C047E8D0AA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebAppPluginsLibrary", "..\samples\WebAppPluginsLibrary\WebAppPluginsLibrary.csproj", "{38CCE0F7-F998-4766-A14A-44C047E8D0AA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAppDotNet5", "..\samples\WebAppDotNet5\WebAppDotNet5.csproj", "{ABB6FB45-C9BA-40FE-A224-370673F8DA7F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -185,6 +187,10 @@ Global {38CCE0F7-F998-4766-A14A-44C047E8D0AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {38CCE0F7-F998-4766-A14A-44C047E8D0AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {38CCE0F7-F998-4766-A14A-44C047E8D0AA}.Release|Any CPU.Build.0 = Release|Any CPU + {ABB6FB45-C9BA-40FE-A224-370673F8DA7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ABB6FB45-C9BA-40FE-A224-370673F8DA7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ABB6FB45-C9BA-40FE-A224-370673F8DA7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ABB6FB45-C9BA-40FE-A224-370673F8DA7F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -214,6 +220,7 @@ Global {E92B0C5D-FFAC-4AB9-B069-869AEED565B0} = {FF3A507D-D242-44F6-8940-49E0B51B6F02} {A5FAE1A5-74A0-4A83-9520-DCABF6610ADE} = {FF3A507D-D242-44F6-8940-49E0B51B6F02} {38CCE0F7-F998-4766-A14A-44C047E8D0AA} = {FF3A507D-D242-44F6-8940-49E0B51B6F02} + {ABB6FB45-C9BA-40FE-A224-370673F8DA7F} = {FF3A507D-D242-44F6-8940-49E0B51B6F02} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AAEBC2B4-FB52-4272-8C25-571FB3CA01E5} From b4bf075b55df729cb8f59b5dbfef699346afd773 Mon Sep 17 00:00:00 2001 From: Mikko Uuksulainen Date: Tue, 5 Jan 2021 13:42:11 +0200 Subject: [PATCH 3/3] Update README with the new .NET 5 Web API sample --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 38a7b5f..92c303d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,9 @@ The following Plugin Framework samples are available from GitHub: #### [Plugin Framework & .NET Console Application](https://github.com/weikio/PluginFramework/tree/master/samples/ConsoleApp) -#### [Plugin Framework & ASP.NET Core](https://github.com/weikio/PluginFramework/tree/master/samples/WebApp) +#### [Plugin Framework & ASP.NET Core 3.1](https://github.com/weikio/PluginFramework/tree/master/samples/WebApp) + +#### [Plugin Framework & ASP.NET Core 5.0](https://github.com/weikio/PluginFramework/tree/master/samples/WebAppDotNet5) #### [Plugin Framework & Blazor](https://github.com/weikio/PluginFramework/tree/master/samples/BlazorApp)