Migrate to .NET Core 3 (#96)

This commit is contained in:
Sipke Schoorstra 2019-10-20 13:30:38 +02:00 committed by GitHub
parent 5d018389ed
commit 5a4da522c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 33 additions and 99 deletions

View file

@ -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);

View file

@ -1,16 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
</ItemGroup>
@ -31,9 +26,4 @@
<_ContentIncludedByDefault Remove="wwwroot\.placeholder" />
</ItemGroup>
<ItemGroup>
<!-- extends watching group to include *.cshtml files for all projects -->
<Watch Include="..\Elsa.Dashboard\**\*.cshtml" />
</ItemGroup>
</Project>

View file

@ -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();
}
}

View file

@ -7,7 +7,7 @@
<a class="nav-link pr-0" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div class="media align-items-center">
<span class="avatar avatar-sm rounded-circle">
<img gravatar-email="@email" gravatar-size="36" alt="My Gravatar" src=""/>
@* <img gravatar-email="@email" gravatar-size="36" alt="My Gravatar" src=""/> *@
</span>
<div class="media-body ml-2 d-none d-lg-block">
<span class="mb-0 text-sm font-weight-bold">@userName</span>

View file

@ -23,15 +23,15 @@
Elsa Dashboard
</title>
<!-- Favicon -->
<link href="~/assets/img/brand/favicon.png" rel="icon" type="image/png">
<link href="~/_content/Elsa.Dashboard/assets/img/brand/favicon.png" rel="icon" type="image/png">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<!-- Icons -->
<link href="~/assets/js/plugins/nucleo/css/nucleo.css" rel="stylesheet"/>
<link href="~/_content/Elsa.Dashboard/assets/js/plugins/nucleo/css/nucleo.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" integrity="sha256-+N4/V/SbAFiW1MPBCXnfnP9QSN3+Keu+NlB+0ev/YKQ=" crossorigin="anonymous" />
<!-- CSS Files -->
<link href="~/assets/css/argon-dashboard.css?v=1.1.0" rel="stylesheet"/>
<link href="~/assets/css/elsa.css?v=1.1.0" rel="stylesheet"/>
<link href="~/_content/Elsa.Dashboard/assets/css/argon-dashboard.css?v=1.1.0" rel="stylesheet"/>
<link href="~/_content/Elsa.Dashboard/assets/css/elsa.css?v=1.1.0" rel="stylesheet"/>
<script type="module" src="https://unpkg.com/@@elsa-workflows/elsa-workflow-designer@0.0.59/dist/elsa-workflow-designer/elsa-workflow-designer.esm.js"></script>
<script nomodule="" src="https://unpkg.com/@@elsa-workflows/elsa-workflow-designer@0.0.59/dist/elsa-workflow-designer/elsa-workflow-designer.js"></script>
@await RenderSectionAsync("HeadScripts", false)
@ -55,8 +55,8 @@
@RenderBody()
</div>
<!-- Core -->
<script src="~/assets/js/plugins/jquery/dist/jquery.min.js"></script>
<script src="~/assets/js/plugins/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/_content/Elsa.Dashboard/assets/js/plugins/jquery/dist/jquery.min.js"></script>
<script src="~/_content/Elsa.Dashboard/assets/js/plugins/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
@await Html.PartialAsync("CustomScripts")
@await RenderSectionAsync("FootScripts", false)
</body>

View file

@ -6,5 +6,5 @@
@await Html.PartialAsync("WorkflowDefinitionEditor")
@section FootScripts{
<script src="~/assets/js/workflow-editor.js"></script>
<script src="~/_content/Elsa.Dashboard/assets/js/workflow-editor.js"></script>
}

View file

@ -6,5 +6,5 @@
@await Html.PartialAsync("WorkflowDefinitionEditor")
@section FootScripts{
<script src="~/assets/js/workflow-editor.js"></script>
<script src="~/_content/Elsa.Dashboard/assets/js/workflow-editor.js"></script>
}

View file

@ -73,5 +73,5 @@
</div>
@section FootScripts{
<script src="~/assets/js/workflow-instance-viewer.js"></script>
<script src="~/_content/Elsa.Dashboard/assets/js/workflow-instance-viewer.js"></script>
}

View file

@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RazorLangVersion>3.0</RazorLangVersion>
<LangVersion>8</LangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PackageVersion>1.0.0</PackageVersion>
<Authors>Sipke Schoorstra</Authors>
<Description>Elsa is a set of workflowing libraries and tools to enable super-fast workflowing capabilities in any .NET Core application.</Description>
@ -11,19 +13,15 @@
<RepositoryUrl>https://github.com/elsa-workflows/elsa-core</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows</PackageTags>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GravatarHelper.AspNetCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.2.0" />
<PackageReference Include="Scrutor.Elsa" Version="3.0.2.20" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="wwwroot\**\*" />
<PackageReference Include="GravatarHelper.AspNetCore" Version="1.1.0" />
<PackageReference Include="Scrutor.Elsa" Version="3.0.2.21" />
</ItemGroup>
<ItemGroup>

View file

@ -13,7 +13,6 @@ using Elsa.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace Elsa.Dashboard.Extensions
{
@ -34,7 +33,6 @@ namespace Elsa.Dashboard.Extensions
.TryAddProvider<ITokenFormatter, JsonTokenFormatter>(ServiceLifetime.Singleton)
.TryAddProvider<ITokenFormatter, YamlTokenFormatter>(ServiceLifetime.Singleton)
.TryAddProvider<ITokenFormatter, XmlTokenFormatter>(ServiceLifetime.Singleton)
.AddSingleton<ITempDataProvider, CookieTempDataProvider>()
.AddHttpContextAccessor()
.AddScoped<IWorkflowPublisher, WorkflowPublisher>()
.AddScoped<INotifier, Notifier>()
@ -49,8 +47,7 @@ namespace Elsa.Dashboard.Extensions
return factory.GetTempData(accessor.HttpContext);
}
);
services.ConfigureOptions<StaticAssetsConfigureOptions>();
services.AddMvcCore(
mvc => { mvc.Filters.AddService<NotifierFilter>(); }
);

View file

@ -1,35 +0,0 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
namespace Elsa.Dashboard.Options
{
internal class StaticAssetsConfigureOptions : IPostConfigureOptions<StaticFileOptions>
{
private readonly IHostingEnvironment environment;
public StaticAssetsConfigureOptions(IHostingEnvironment environment)
{
this.environment = environment;
}
public void PostConfigure(string name, StaticFileOptions options)
{
options.ContentTypeProvider = options.ContentTypeProvider ?? new FileExtensionContentTypeProvider();
if (options.FileProvider == null && environment.WebRootFileProvider == null)
{
throw new InvalidOperationException("Missing FileProvider.");
}
options.FileProvider = options.FileProvider ?? environment.WebRootFileProvider;
var embeddedFileProvider = new ManifestEmbeddedFileProvider(GetType().Assembly, "wwwroot");
options.FileProvider = new CompositeFileProvider(options.FileProvider, embeddedFileProvider);
}
}
}

View file

@ -3,7 +3,6 @@ using Elsa.WorkflowDesigner.ViewModels;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Workflow = Elsa.Services.Models.Workflow;
namespace Elsa.WorkflowDesigner.ViewComponents
{

View file

@ -20,7 +20,9 @@ namespace Elsa.Persistence.EntityFrameworkCore.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);