From 5a4da522c7929ce3f89a1d705a9e538dfd21248c Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 20 Oct 2019 13:30:38 +0200 Subject: [PATCH] Migrate to .NET Core 3 (#96) --- .../WorkflowDefinitionExtensions.cs | 4 +- .../Elsa.Dashboard.Web.csproj | 12 +----- src/dashboard/Elsa.Dashboard.Web/Startup.cs | 37 +++++-------------- .../Elsa/Views/Shared/UserMenuItems.cshtml | 2 +- .../Areas/Elsa/Views/Shared/_Layout.cshtml | 12 +++--- .../Views/WorkflowDefinition/Create.cshtml | 2 +- .../Elsa/Views/WorkflowDefinition/Edit.cshtml | 2 +- .../Views/WorkflowInstance/Details.cshtml | 2 +- .../Elsa.Dashboard/Elsa.Dashboard.csproj | 14 +++---- .../Extensions/ServiceCollectionExtensions.cs | 5 +-- .../Options/StaticAssetsConfigureOptions.cs | 35 ------------------ .../WorkflowDesignerViewComponent.cs | 1 - .../WorkflowDefinitionExtensions.cs | 4 +- 13 files changed, 33 insertions(+), 99 deletions(-) delete mode 100644 src/dashboard/Elsa.Dashboard/Options/StaticAssetsConfigureOptions.cs diff --git a/src/core/Elsa.Core/Extensions/WorkflowDefinitionExtensions.cs b/src/core/Elsa.Core/Extensions/WorkflowDefinitionExtensions.cs index 70a697ecf..4559050e5 100644 --- a/src/core/Elsa.Core/Extensions/WorkflowDefinitionExtensions.cs +++ b/src/core/Elsa.Core/Extensions/WorkflowDefinitionExtensions.cs @@ -19,7 +19,9 @@ namespace Elsa.Extensions else if (version.IsLatestOrPublished) query = query.Where(x => x.IsPublished || x.IsLatest); else if (version.AllVersions) - query = query; + { + // Nothing to filter. + } else if (version.Version > 0) query = query.Where(x => x.Version == version.Version); diff --git a/src/dashboard/Elsa.Dashboard.Web/Elsa.Dashboard.Web.csproj b/src/dashboard/Elsa.Dashboard.Web/Elsa.Dashboard.Web.csproj index 08695ff33..ec50c007a 100644 --- a/src/dashboard/Elsa.Dashboard.Web/Elsa.Dashboard.Web.csproj +++ b/src/dashboard/Elsa.Dashboard.Web/Elsa.Dashboard.Web.csproj @@ -1,16 +1,11 @@  - netcoreapp2.2 + netcoreapp3.0 full - - - - - @@ -31,9 +26,4 @@ <_ContentIncludedByDefault Remove="wwwroot\.placeholder" /> - - - - - diff --git a/src/dashboard/Elsa.Dashboard.Web/Startup.cs b/src/dashboard/Elsa.Dashboard.Web/Startup.cs index 52b177639..929c9b5fb 100644 --- a/src/dashboard/Elsa.Dashboard.Web/Startup.cs +++ b/src/dashboard/Elsa.Dashboard.Web/Startup.cs @@ -1,47 +1,24 @@ -using System.IO; -using Elsa.Dashboard.Extensions; +using Elsa.Dashboard.Extensions; using Elsa.Persistence.EntityFrameworkCore.Extensions; -using Elsa.Services.Models; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.FileProviders; namespace Elsa.Dashboard.Web { public class Startup { - public Startup(IConfiguration configuration, IHostingEnvironment environment) + public Startup(IConfiguration configuration) { Configuration = configuration; - Environment = environment; } private IConfiguration Configuration { get; } - private IHostingEnvironment Environment { get; } public void ConfigureServices(IServiceCollection services) { - services - .AddMvc( /*options => options.Conventions.Add(new AddLocalhostFilterConvention())*/) - .SetCompatibilityVersion(CompatibilityVersion.Latest) - - // This is entirely optional and only useful when developing the Elsa.Dashboard project. - .AddRazorOptions( - options => - { - // Workaround to get Razor views in Elsa.Dashboard recompiled when changing .cshtml. - if (Environment.IsDevelopment()) - options.FileProviders.Add( - new PhysicalFileProvider( - Path.Combine(Environment.ContentRootPath, @"..\Elsa.Dashboard") - ) - ); - } - ); + services.AddControllersWithViews(); services .AddEntityFrameworkCore( @@ -53,12 +30,16 @@ namespace Elsa.Dashboard.Web .AddElsaDashboard(options => options.DiscoverActivities()); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app) { app .UseDeveloperExceptionPage() .UseStaticFiles() - .UseMvcWithDefaultRoute() + .UseRouting() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }) .UseWelcomePage(); } } diff --git a/src/dashboard/Elsa.Dashboard/Areas/Elsa/Views/Shared/UserMenuItems.cshtml b/src/dashboard/Elsa.Dashboard/Areas/Elsa/Views/Shared/UserMenuItems.cshtml index 4f4c0b163..1ee6625b2 100644 --- a/src/dashboard/Elsa.Dashboard/Areas/Elsa/Views/Shared/UserMenuItems.cshtml +++ b/src/dashboard/Elsa.Dashboard/Areas/Elsa/Views/Shared/UserMenuItems.cshtml @@ -7,7 +7,7 @@