Skip to content
Permalink
Browse files

Migrate to .NET Core 3.0 - preview 9

  • Loading branch information
Groxan committed Sep 13, 2019
1 parent af6bbf7 commit 612098756c84984c803d8b37ca112f423946f667
@@ -10,8 +10,8 @@

namespace Tzkt.Api.Controllers
{
[Route("api/[controller]")]
[ApiController]
[Route("api/[controller]")]
public class StateController : ControllerBase
{
private readonly ApiContext Db;
@@ -24,7 +24,7 @@ public StateController(ApiContext db)
public async Task<ActionResult<object>> Get()
{
var state = await Db.AppState.FirstOrDefaultAsync();
return new
return new
{
hash = state.Hash,
level = state.Level,
@@ -1,11 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Tzkt.Api
@@ -14,11 +13,14 @@ public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -8,8 +8,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

using Tzkt.Data;

@@ -31,18 +31,24 @@ public void ConfigureServices(IServiceCollection services)
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"));
});

services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddControllers();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseMvc();
app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
@@ -1,15 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Tzkt.Data\Tzkt.Data.csproj" />
</ItemGroup>
@@ -5,7 +5,9 @@

"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.2.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.0.0-preview9" />
</ItemGroup>

</Project>

This file was deleted.

@@ -1,10 +1,11 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using Tzkt.Data;
using Tzkt.Sync.Services;
@@ -13,27 +14,21 @@ namespace Tzkt.Sync
{
public class Program
{
public static async Task Main(string[] args)
public static void Main(string[] args)
{
var environment = Environment.GetEnvironmentVariable("TZKT_Environment")
?? EnvironmentName.Production;
CreateHostBuilder(args).Build().Run();
}

var builder = new HostBuilder()
.UseEnvironment(environment)
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostContext, config) =>
{
config.AddJsonFile(
$"appsettings.json",
optional: false,
reloadOnChange: false);

config.AddJsonFile(
$"appsettings.{environment}.json",
optional: true,
reloadOnChange: false);

config.AddEnvironmentVariables("TZKT_");
})
.ConfigureHostConfiguration(configHost =>
{
configHost.AddEnvironmentVariables(prefix: "TZKT_");
})
.ConfigureServices((hostContext, services) =>
{
services.AddEntityFrameworkNpgsql()
@@ -47,18 +42,8 @@ public static async Task Main(string[] args)

services.AddTezosNode();
services.AddTezosProtocols();
services.AddHostedService<Observer>();
})
.ConfigureLogging((hostContext, logging) =>
{
logging.AddConfiguration(
hostContext.Configuration.GetSection("Logging"));

logging.AddConsole();
logging.AddDebug();
services.AddHostedService<Observer>();
});

await builder.RunConsoleAsync();
}
}
}
@@ -1,35 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<StartupObject />
<TargetFramework>netcoreapp3.0</TargetFramework>
<UserSecretsId>dotnet-Tzkt.Sync-0D5638DC-A8DD-449C-8F4B-5DD8ED259849</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Netezos.Rpc" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0-preview9.19423.4" />
<PackageReference Include="Netezos.Rpc" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Tzkt.Data\Tzkt.Data.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
@@ -14,7 +14,7 @@ public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<TzktContex
public TzktContext CreateDbContext(string[] args)
{
var environment = Environment.GetEnvironmentVariable("TZKT_Environment")
?? EnvironmentName.Production;
?? Environments.Production;

IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
@@ -11,7 +11,9 @@

"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
@@ -1,43 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28917.181
VisualStudioVersion = 16.0.29230.61
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tzkt.Data", "Tzkt.Data\Tzkt.Data.csproj", "{5456AEA8-4FF7-40F0-A467-EFA2D9899899}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tzkt.Api", "Tzkt.Api\Tzkt.Api.csproj", "{48559098-2B55-4822-8EAC-EFB30E7E7D99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tzkt.Sync", "Tzkt.Sync\Tzkt.Sync.csproj", "{11913B5B-5011-4CDA-A2CD-13FBB3BF2FD8}"
ProjectSection(ProjectDependencies) = postProject
{5456AEA8-4FF7-40F0-A467-EFA2D9899899} = {5456AEA8-4FF7-40F0-A467-EFA2D9899899}
EndProjectSection
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tzkt.Data", "Tzkt.Data\Tzkt.Data.csproj", "{C8AEA17C-C791-4E15-949F-38D5A7829F29}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tzkt.Api", "Tzkt.Api\Tzkt.Api.csproj", "{77BF0371-B088-4FB7-B9B7-A9EA05D0C4EB}"
ProjectSection(ProjectDependencies) = postProject
{5456AEA8-4FF7-40F0-A467-EFA2D9899899} = {5456AEA8-4FF7-40F0-A467-EFA2D9899899}
EndProjectSection
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tzkt.Sync", "Tzkt.Sync\Tzkt.Sync.csproj", "{2A9CB3C6-92C4-4CEA-9091-821CB2A1F955}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5456AEA8-4FF7-40F0-A467-EFA2D9899899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5456AEA8-4FF7-40F0-A467-EFA2D9899899}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5456AEA8-4FF7-40F0-A467-EFA2D9899899}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5456AEA8-4FF7-40F0-A467-EFA2D9899899}.Release|Any CPU.Build.0 = Release|Any CPU
{11913B5B-5011-4CDA-A2CD-13FBB3BF2FD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11913B5B-5011-4CDA-A2CD-13FBB3BF2FD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11913B5B-5011-4CDA-A2CD-13FBB3BF2FD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11913B5B-5011-4CDA-A2CD-13FBB3BF2FD8}.Release|Any CPU.Build.0 = Release|Any CPU
{77BF0371-B088-4FB7-B9B7-A9EA05D0C4EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77BF0371-B088-4FB7-B9B7-A9EA05D0C4EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77BF0371-B088-4FB7-B9B7-A9EA05D0C4EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77BF0371-B088-4FB7-B9B7-A9EA05D0C4EB}.Release|Any CPU.Build.0 = Release|Any CPU
{48559098-2B55-4822-8EAC-EFB30E7E7D99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48559098-2B55-4822-8EAC-EFB30E7E7D99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48559098-2B55-4822-8EAC-EFB30E7E7D99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48559098-2B55-4822-8EAC-EFB30E7E7D99}.Release|Any CPU.Build.0 = Release|Any CPU
{C8AEA17C-C791-4E15-949F-38D5A7829F29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8AEA17C-C791-4E15-949F-38D5A7829F29}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8AEA17C-C791-4E15-949F-38D5A7829F29}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8AEA17C-C791-4E15-949F-38D5A7829F29}.Release|Any CPU.Build.0 = Release|Any CPU
{2A9CB3C6-92C4-4CEA-9091-821CB2A1F955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A9CB3C6-92C4-4CEA-9091-821CB2A1F955}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A9CB3C6-92C4-4CEA-9091-821CB2A1F955}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A9CB3C6-92C4-4CEA-9091-821CB2A1F955}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3920339A-3F2D-4C8D-9067-CE2D83C17618}
SolutionGuid = {3C6B91F9-9AA9-4BAC-A1CC-CF5CF5E59F74}
EndGlobalSection
EndGlobal

0 comments on commit 6120987

Please sign in to comment.
You can’t perform that action at this time.