From 2d21dd5bb6552b940f5e5b3396a5396f064d6108 Mon Sep 17 00:00:00 2001 From: f7Q Date: Sat, 28 Oct 2017 11:41:44 +0900 Subject: [PATCH 1/4] console update --- console/global.json | 3 +-- console/src/src.csproj | 8 ++++---- ef/NuGet.config | 14 +++++++------- ef/src/Models/Company.cs | 22 +++++++++++----------- ef/src/Models/Employee.cs | 20 ++++++++++---------- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/console/global.json b/console/global.json index d76e72f..5d5d3a7 100644 --- a/console/global.json +++ b/console/global.json @@ -1,6 +1,5 @@ { - "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.0.2" } } \ No newline at end of file diff --git a/console/src/src.csproj b/console/src/src.csproj index 698b553..ce86ae9 100644 --- a/console/src/src.csproj +++ b/console/src/src.csproj @@ -1,13 +1,13 @@  - netcoreapp1.1 + netcoreapp2.0 portable src Exe src $(PackageTargetFallback) - 1.1.2 + 2.0.0 @@ -15,8 +15,8 @@ win10-x64 - - + + diff --git a/ef/NuGet.config b/ef/NuGet.config index d2c31a0..7604d00 100644 --- a/ef/NuGet.config +++ b/ef/NuGet.config @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/ef/src/Models/Company.cs b/ef/src/Models/Company.cs index a4835c2..560faeb 100644 --- a/ef/src/Models/Company.cs +++ b/ef/src/Models/Company.cs @@ -1,12 +1,12 @@ -using System.Collections.Generic; - -namespace ef.Models -{ - public class Company - { - public int id { get; set; } - public string Name { get; set; } - public int Capital { get; set; } - public List Employees { get; set; } - } +using System.Collections.Generic; + +namespace ef.Models +{ + public class Company + { + public int id { get; set; } + public string Name { get; set; } + public int Capital { get; set; } + public List Employees { get; set; } + } } \ No newline at end of file diff --git a/ef/src/Models/Employee.cs b/ef/src/Models/Employee.cs index 2b416ed..c52e699 100644 --- a/ef/src/Models/Employee.cs +++ b/ef/src/Models/Employee.cs @@ -1,11 +1,11 @@ -using System.Collections.Generic; - -namespace ef.Models -{ - public class Employee - { - public int id { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - } +using System.Collections.Generic; + +namespace ef.Models +{ + public class Employee + { + public int id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + } } \ No newline at end of file From f4db76778e67894b1c49537e1df393b98004eb02 Mon Sep 17 00:00:00 2001 From: f7Q Date: Sun, 29 Oct 2017 13:06:59 +0900 Subject: [PATCH 2/4] update dotnet core 2.0 --- PortableLib/global.json | 3 +- PortableLib/src/Sample/Sample.csproj | 8 +-- .../src/WpfApplication/WpfApplication.csproj | 5 ++ cakebuild/NuGet.config | 3 +- cakebuild/build.cake | 4 +- cakebuild/global.json | 3 +- cakebuild/src/Sample/Sample.csproj | 6 +-- .../test/Sample.Tests/Sample.Tests.csproj | 11 ++-- ef/global.json | 3 +- ef/src/Models/CoreExampleContext.cs | 4 +- ef/src/Program.cs | 5 +- ef/src/appsettings.json | 2 +- ef/src/src.csproj | 50 ++++++++----------- scaffold/global.json | 3 +- scaffold/src/scaffold.txt | 4 +- scaffold/src/src.csproj | 18 +++---- 16 files changed, 64 insertions(+), 68 deletions(-) diff --git a/PortableLib/global.json b/PortableLib/global.json index d76e72f..5d5d3a7 100644 --- a/PortableLib/global.json +++ b/PortableLib/global.json @@ -1,6 +1,5 @@ { - "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.0.2" } } \ No newline at end of file diff --git a/PortableLib/src/Sample/Sample.csproj b/PortableLib/src/Sample/Sample.csproj index a53f498..8ca81ca 100644 --- a/PortableLib/src/Sample/Sample.csproj +++ b/PortableLib/src/Sample/Sample.csproj @@ -1,13 +1,13 @@  - netstandard1.6;net461 + netstandard2.0;net461 portable true Sample Sample - $(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+net461+win8 - 1.6.1 + $(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+net461+win8 + 2.0.1 @@ -15,4 +15,6 @@ + + diff --git a/PortableLib/src/WpfApplication/WpfApplication.csproj b/PortableLib/src/WpfApplication/WpfApplication.csproj index 7b041c0..2e16089 100644 --- a/PortableLib/src/WpfApplication/WpfApplication.csproj +++ b/PortableLib/src/WpfApplication/WpfApplication.csproj @@ -131,6 +131,11 @@ Sample + + + 2.0.1 + + - + diff --git a/cakebuild/build.cake b/cakebuild/build.cake index fa87363..82480ee 100644 --- a/cakebuild/build.cake +++ b/cakebuild/build.cake @@ -9,8 +9,8 @@ var buildArtifacts = Directory("./artifacts/packages"); var isAppVeyor = AppVeyor.IsRunningOnAppVeyor; var isWindows = IsRunningOnWindows(); -var netcore = "netcoreapp1.1"; -var netstandard = "netstandard1.6"; +var netcore = "netcoreapp2.0"; +var netstandard = "netstandard2.0"; /////////////////////////////////////////////////////////////////////////////// // Clean diff --git a/cakebuild/global.json b/cakebuild/global.json index 194114a..5d5d3a7 100644 --- a/cakebuild/global.json +++ b/cakebuild/global.json @@ -1,6 +1,5 @@ { - "projects": [ "src", "test" ], "sdk": { - "version": "1.1.0" + "version": "2.0.2" } } \ No newline at end of file diff --git a/cakebuild/src/Sample/Sample.csproj b/cakebuild/src/Sample/Sample.csproj index 7ca0712..c8188ed 100644 --- a/cakebuild/src/Sample/Sample.csproj +++ b/cakebuild/src/Sample/Sample.csproj @@ -1,13 +1,13 @@  - netcoreapp1.1 + netcoreapp2.0 portable true Sample Sample - 1.1.2 - $(PackageTargetFallback);dotnet5.4;portable-net451+win8 + 2.0.0 + $(PackageTargetFallback) diff --git a/cakebuild/test/Sample.Tests/Sample.Tests.csproj b/cakebuild/test/Sample.Tests/Sample.Tests.csproj index 36e9ee3..8dfac07 100644 --- a/cakebuild/test/Sample.Tests/Sample.Tests.csproj +++ b/cakebuild/test/Sample.Tests/Sample.Tests.csproj @@ -1,13 +1,14 @@ - netcoreapp1.1 + netcoreapp2.0 portable Sample.Tests Sample.Tests true - $(PackageTargetFallback);dotnet5.4;portable-net451+win8 - 1.1.2 + $(PackageTargetFallback) + 2.0.0 + false @@ -15,10 +16,10 @@ - + - + diff --git a/ef/global.json b/ef/global.json index d76e72f..5d5d3a7 100644 --- a/ef/global.json +++ b/ef/global.json @@ -1,6 +1,5 @@ { - "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.0.2" } } \ No newline at end of file diff --git a/ef/src/Models/CoreExampleContext.cs b/ef/src/Models/CoreExampleContext.cs index 7d1965a..120fe48 100644 --- a/ef/src/Models/CoreExampleContext.cs +++ b/ef/src/Models/CoreExampleContext.cs @@ -4,6 +4,8 @@ namespace ef.Models { + using System; + public class CoreExampleContext : DbContext { public DbSet Company { get; set; } @@ -42,7 +44,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) } if (dbkind.Equals("inmemory")) { - optionsBuilder.UseInMemoryDatabase(); + optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); } } } diff --git a/ef/src/Program.cs b/ef/src/Program.cs index 9a24c13..73f9faa 100644 --- a/ef/src/Program.cs +++ b/ef/src/Program.cs @@ -15,6 +15,7 @@ namespace ef { public class Program { + /* private static DbContextOptions CreateNewContextOptions() { var serviceProvider = new ServiceCollection() @@ -27,6 +28,8 @@ private static DbContextOptions CreateNewContextOptions() return builder.Options; } + */ + private static IConfigurationRoot Configuration { get; set; } private static IHostingEnvironment HostingEnvironment { get; set; } @@ -73,7 +76,7 @@ public static void Main(string[] args) service.AddEntityFrameworkInMemoryDatabase(); service.AddDbContext(options => { - options.UseInMemoryDatabase(); + options.UseInMemoryDatabase(Guid.NewGuid().ToString()); }); } diff --git a/ef/src/appsettings.json b/ef/src/appsettings.json index 8114dea..5ab31b1 100644 --- a/ef/src/appsettings.json +++ b/ef/src/appsettings.json @@ -2,7 +2,7 @@ "Data": { "DefaultConnection": { "ConnectionDBString": "sqlite", - "ConnectionString": "Data Source=..\\..\\..\\db.sqlite" + "ConnectionString": "Data Source=db.sqlite" } /* "DefaultConnection": { diff --git a/ef/src/src.csproj b/ef/src/src.csproj index ee1b30a..3b5f704 100644 --- a/ef/src/src.csproj +++ b/ef/src/src.csproj @@ -1,46 +1,36 @@  - netcoreapp1.1 + netcoreapp2.0 portable src Exe src - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 - win10-x64;osx.10.11-x64;ubuntu.16.04-x64 - 1.1.2 + $(PackageTargetFallback); + win7-x86;win10-x64;osx.10.11-x64;ubuntu.16.04-x64 + 2.0.0 - - All - - - - - - All - - - All - - - All - - - All - - - - - - - - + + + + + + + + + + + + + + + - + diff --git a/scaffold/global.json b/scaffold/global.json index d76e72f..5d5d3a7 100644 --- a/scaffold/global.json +++ b/scaffold/global.json @@ -1,6 +1,5 @@ { - "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.0.2" } } \ No newline at end of file diff --git a/scaffold/src/scaffold.txt b/scaffold/src/scaffold.txt index 0030243..20ccac5 100644 --- a/scaffold/src/scaffold.txt +++ b/scaffold/src/scaffold.txt @@ -1 +1,3 @@ -dotnet ef dbcontext scaffold "Data Source=..\..\..\db.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models \ No newline at end of file +dotnet ef dbcontext scaffold "Data Source=db.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models +dotnet ef dbcontext scaffold "Data Source=db.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models -t Company +dotnet ef dbcontext scaffold "Data Source=db.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models -c AbcDbContext \ No newline at end of file diff --git a/scaffold/src/src.csproj b/scaffold/src/src.csproj index 2638cc6..8a65e83 100644 --- a/scaffold/src/src.csproj +++ b/scaffold/src/src.csproj @@ -1,29 +1,25 @@  - netcoreapp1.1 + netcoreapp2.0 portable true src Exe src true - 1.1.2 - $(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+win8 + 2.0.0 + $(PackageTargetFallback); - - - All - - - All - + + + - + From 638166d5cdcc494cb64b3d19ae255fba828c196e Mon Sep 17 00:00:00 2001 From: f7Q Date: Sat, 7 Jul 2018 23:16:44 +0900 Subject: [PATCH 3/4] update 2.1 sdk --- DapperSample/global.json | 2 +- .../src/DapperSample/DapperSample.csproj | 38 ++------ DapperSample/src/DapperSample/Startup.cs | 21 ++++- GroongaSample/global.json | 2 +- GroongaSample/src/WebApiSample/Program.cs | 14 ++- .../src/WebApiSample/WebApiSample.csproj | 36 ++------ PortableLib/global.json | 2 +- PortableLib/src/Sample/Sample.csproj | 3 +- .../src/WpfApplication/WpfApplication.csproj | 2 +- WebApiFileUploadSample/global.json | 2 +- .../Controllers/FilesController.cs | 10 +-- .../Controllers/ValuesController.cs | 2 +- .../src/WebApiFileUploadSample/Program.cs | 19 ++-- .../WebApiFileUploadSample.csproj | 16 +--- .../WebApiFileUploadSample/appsettings.json | 2 +- WebApiRebootSample/global.json | 2 +- .../Controllers/ValuesController.cs | 25 ------ .../src/WebApiRebootSample/Program.cs | 18 ++-- .../WebApiRebootSample.csproj | 8 +- WebApiSample/global.json | 2 +- WebApiSample/src/WebApiSample/Program.cs | 14 ++- .../src/WebApiSample/WebApiSample.csproj | 36 ++------ WebApiScaffoldSample/global.json | 2 +- .../Controllers/ValuesController.cs | 87 ++++++++----------- .../src/WebApiScaffoldSample/Program.cs | 21 ++--- .../WebApiScaffoldSample.csproj | 57 ++---------- WebAppScaffoldSample/global.json | 2 +- .../src/WebApplication/.bowerrc | 3 +- .../src/WebApplication/Startup.cs | 3 +- .../src/WebApplication/WebApplication.csproj | 46 ++-------- .../src/WebApplication/appsettings.json | 2 +- cakebuild/build.cake | 2 +- cakebuild/global.json | 2 +- .../test/Sample.Tests/Sample.Tests.csproj | 2 +- console/global.json | 2 +- console/src/src.csproj | 6 +- ef/global.json | 2 +- ef/src/Program.cs | 3 +- ef/src/src.csproj | 33 ++----- scaffold/global.json | 2 +- scaffold/src/src.csproj | 13 +-- 41 files changed, 170 insertions(+), 396 deletions(-) diff --git a/DapperSample/global.json b/DapperSample/global.json index d76e72f..1cc381b 100644 --- a/DapperSample/global.json +++ b/DapperSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/DapperSample/src/DapperSample/DapperSample.csproj b/DapperSample/src/DapperSample/DapperSample.csproj index 6cf11ec..dc53612 100644 --- a/DapperSample/src/DapperSample/DapperSample.csproj +++ b/DapperSample/src/DapperSample/DapperSample.csproj @@ -1,46 +1,24 @@  - netcoreapp1.1 + netcoreapp2.1 true DapperSample Exe DapperSample - 1.1.2 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + 2.1.0 + $(PackageTargetFallback) - - - - - - - - - - - - + + - - - - - - - - - All - - + + + - - - - diff --git a/DapperSample/src/DapperSample/Startup.cs b/DapperSample/src/DapperSample/Startup.cs index 9f100a9..5d8fcec 100644 --- a/DapperSample/src/DapperSample/Startup.cs +++ b/DapperSample/src/DapperSample/Startup.cs @@ -47,7 +47,8 @@ public void ConfigureServices(IServiceCollection services) options.UseSqlite(Configuration["Data:DefaultConnection:ConnectionString"]); }); } - if(dbkind.Equals("sqlserver")) + + if (dbkind.Equals("sqlserver")) { services.AddEntityFrameworkSqlServer(); services.AddDbContext(options => @@ -55,7 +56,8 @@ public void ConfigureServices(IServiceCollection services) options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]); }); } - if(dbkind.Equals("postgresql")) + + if (dbkind.Equals("postgresql")) { services.AddEntityFrameworkNpgsql(); services.AddDbContext(options => @@ -63,7 +65,8 @@ public void ConfigureServices(IServiceCollection services) options.UseNpgsql(Configuration["Data:DefaultConnection:ConnectionString"]); }); } - if(dbkind.Equals("inmemory")) + + if (dbkind.Equals("inmemory")) { services.AddEntityFrameworkInMemoryDatabase(); services.AddDbContext(options => @@ -71,6 +74,7 @@ public void ConfigureServices(IServiceCollection services) options.UseInMemoryDatabase(); }); } + // Add framework services. services.AddMvc(); services.AddSwaggerGen(c => @@ -108,6 +112,17 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF { c.SwaggerEndpoint("/api-docs/v1/swagger.json", "My API V1"); }); + + Initialize(app); + } + + private void Initialize(IApplicationBuilder app) + { + using (var serviceScope = app.ApplicationServices.GetRequiredService().CreateScope()) + { + var context = serviceScope.ServiceProvider.GetService(); + context.Database.EnsureCreated(); + } } } } diff --git a/GroongaSample/global.json b/GroongaSample/global.json index d76e72f..1cc381b 100644 --- a/GroongaSample/global.json +++ b/GroongaSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/GroongaSample/src/WebApiSample/Program.cs b/GroongaSample/src/WebApiSample/Program.cs index da94e49..326817d 100644 --- a/GroongaSample/src/WebApiSample/Program.cs +++ b/GroongaSample/src/WebApiSample/Program.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore; namespace WebApiSample { @@ -12,14 +13,11 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); + CreateWebHostBuilder(args).Build().Run(); } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } diff --git a/GroongaSample/src/WebApiSample/WebApiSample.csproj b/GroongaSample/src/WebApiSample/WebApiSample.csproj index eaa3cc4..1550be9 100644 --- a/GroongaSample/src/WebApiSample/WebApiSample.csproj +++ b/GroongaSample/src/WebApiSample/WebApiSample.csproj @@ -1,45 +1,21 @@ - netcoreapp1.1 + netcoreapp2.1 true WebApiSample Exe WebApiSample - 1.1.2 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + 2.1.0 + $(PackageTargetFallback) - - - - - - - - - - - + - - - All - - - - - - - - All - - - - - + + diff --git a/PortableLib/global.json b/PortableLib/global.json index 5d5d3a7..386035d 100644 --- a/PortableLib/global.json +++ b/PortableLib/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.2" + "version": "2.1.300" } } \ No newline at end of file diff --git a/PortableLib/src/Sample/Sample.csproj b/PortableLib/src/Sample/Sample.csproj index 8ca81ca..81851f6 100644 --- a/PortableLib/src/Sample/Sample.csproj +++ b/PortableLib/src/Sample/Sample.csproj @@ -6,8 +6,7 @@ true Sample Sample - $(PackageTargetFallback);dotnet5.6;dnxcore50;portable-net45+net461+win8 - 2.0.1 + $(PackageTargetFallback); diff --git a/PortableLib/src/WpfApplication/WpfApplication.csproj b/PortableLib/src/WpfApplication/WpfApplication.csproj index 2e16089..11e72e5 100644 --- a/PortableLib/src/WpfApplication/WpfApplication.csproj +++ b/PortableLib/src/WpfApplication/WpfApplication.csproj @@ -1,5 +1,5 @@  - + Debug diff --git a/WebApiFileUploadSample/global.json b/WebApiFileUploadSample/global.json index d76e72f..1cc381b 100644 --- a/WebApiFileUploadSample/global.json +++ b/WebApiFileUploadSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/FilesController.cs b/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/FilesController.cs index 9db8666..52566b4 100644 --- a/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/FilesController.cs +++ b/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/FilesController.cs @@ -30,7 +30,7 @@ public IActionResult Get() var list = _dbContext.Values.ToList(); return Ok(list); } - catch (Exception ex) + catch { return NotFound(); } @@ -46,7 +46,7 @@ public IActionResult Get(string name) var val = _dbContext.Values.FirstOrDefault(d => d.Name == name); return File(val.Image, "image/png"); } - catch (Exception ex) + catch { return NotFound(); } @@ -73,7 +73,7 @@ public async Task PostFile(IFormFile uploadedFile) return Ok(); } - catch (Exception ex) + catch { return BadRequest(); } @@ -90,7 +90,7 @@ public IActionResult Delete(int id) _dbContext.SaveChanges(); return Ok(); } - catch (Exception ex) + catch { return NotFound(); } @@ -106,7 +106,7 @@ public IActionResult Delete(string name) _dbContext.SaveChanges(); return Ok(); } - catch (Exception ex) + catch { return NotFound(); } diff --git a/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/ValuesController.cs b/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/ValuesController.cs index 3fcbeae..05a8a4e 100644 --- a/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/ValuesController.cs +++ b/WebApiFileUploadSample/src/WebApiFileUploadSample/Controllers/ValuesController.cs @@ -33,7 +33,7 @@ public async Task PostFile(IFormFile uploadedFile) return Ok(); } - catch(Exception ex) + catch { return BadRequest(); } diff --git a/WebApiFileUploadSample/src/WebApiFileUploadSample/Program.cs b/WebApiFileUploadSample/src/WebApiFileUploadSample/Program.cs index 0363ad7..936b4fd 100644 --- a/WebApiFileUploadSample/src/WebApiFileUploadSample/Program.cs +++ b/WebApiFileUploadSample/src/WebApiFileUploadSample/Program.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -12,14 +8,11 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); + CreateWebHostBuilder(args).Build().Run(); } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } diff --git a/WebApiFileUploadSample/src/WebApiFileUploadSample/WebApiFileUploadSample.csproj b/WebApiFileUploadSample/src/WebApiFileUploadSample/WebApiFileUploadSample.csproj index 011949f..7618ff0 100644 --- a/WebApiFileUploadSample/src/WebApiFileUploadSample/WebApiFileUploadSample.csproj +++ b/WebApiFileUploadSample/src/WebApiFileUploadSample/WebApiFileUploadSample.csproj @@ -1,22 +1,12 @@  - netcoreapp1.1 - portable-net45+win8 + netcoreapp2.1 - - - - - - - - - - - + + diff --git a/WebApiFileUploadSample/src/WebApiFileUploadSample/appsettings.json b/WebApiFileUploadSample/src/WebApiFileUploadSample/appsettings.json index ba0b83a..59c4ae0 100644 --- a/WebApiFileUploadSample/src/WebApiFileUploadSample/appsettings.json +++ b/WebApiFileUploadSample/src/WebApiFileUploadSample/appsettings.json @@ -2,7 +2,7 @@ "Data": { "DefaultConnection": { "ConnectionDBString": "sqlite", - "ConnectionString": "Data Source=..\\..\\..\\db.sqlite" + "ConnectionString": "Data Source=db.sqlite" } /* "DefaultConnection": { diff --git a/WebApiRebootSample/global.json b/WebApiRebootSample/global.json index d76e72f..1cc381b 100644 --- a/WebApiRebootSample/global.json +++ b/WebApiRebootSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/WebApiRebootSample/src/WebApiRebootSample/Controllers/ValuesController.cs b/WebApiRebootSample/src/WebApiRebootSample/Controllers/ValuesController.cs index 16d7e5a..de3ddee 100644 --- a/WebApiRebootSample/src/WebApiRebootSample/Controllers/ValuesController.cs +++ b/WebApiRebootSample/src/WebApiRebootSample/Controllers/ValuesController.cs @@ -52,30 +52,5 @@ public void GetSafeRestart() return ; } - - // GET api/values/5 - [HttpGet("{id}")] - public string Get(int id) - { - return "value"; - } - - // POST api/values - [HttpPost] - public void Post([FromBody]string value) - { - } - - // PUT api/values/5 - [HttpPut("{id}")] - public void Put(int id, [FromBody]string value) - { - } - - // DELETE api/values/5 - [HttpDelete("{id}")] - public void Delete(int id) - { - } } } diff --git a/WebApiRebootSample/src/WebApiRebootSample/Program.cs b/WebApiRebootSample/src/WebApiRebootSample/Program.cs index 0728907..a3fe133 100644 --- a/WebApiRebootSample/src/WebApiRebootSample/Program.cs +++ b/WebApiRebootSample/src/WebApiRebootSample/Program.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using System.Diagnostics; @@ -17,14 +13,10 @@ public static void Main(string[] args) var processid = process.Id; //System.Threading.Mutex - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); + CreateWebHostBuilder(args).Build().Run(); } + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } diff --git a/WebApiRebootSample/src/WebApiRebootSample/WebApiRebootSample.csproj b/WebApiRebootSample/src/WebApiRebootSample/WebApiRebootSample.csproj index f550d8c..8858db7 100644 --- a/WebApiRebootSample/src/WebApiRebootSample/WebApiRebootSample.csproj +++ b/WebApiRebootSample/src/WebApiRebootSample/WebApiRebootSample.csproj @@ -1,13 +1,11 @@ - + - netcoreapp1.1 + netcoreapp2.1 - - - + diff --git a/WebApiSample/global.json b/WebApiSample/global.json index d76e72f..1cc381b 100644 --- a/WebApiSample/global.json +++ b/WebApiSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/WebApiSample/src/WebApiSample/Program.cs b/WebApiSample/src/WebApiSample/Program.cs index da94e49..326817d 100644 --- a/WebApiSample/src/WebApiSample/Program.cs +++ b/WebApiSample/src/WebApiSample/Program.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore; namespace WebApiSample { @@ -12,14 +13,11 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); + CreateWebHostBuilder(args).Build().Run(); } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } diff --git a/WebApiSample/src/WebApiSample/WebApiSample.csproj b/WebApiSample/src/WebApiSample/WebApiSample.csproj index e3e7ee4..7a8fc07 100644 --- a/WebApiSample/src/WebApiSample/WebApiSample.csproj +++ b/WebApiSample/src/WebApiSample/WebApiSample.csproj @@ -1,44 +1,20 @@ - netcoreapp1.1 + netcoreapp2.1 true WebApiSample Exe WebApiSample - 1.1.2 - $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + 2.1.0 + $(PackageTargetFallback) - - - - - - - - - - - + - - - - - - - - - - All - - - - - - + + diff --git a/WebApiScaffoldSample/global.json b/WebApiScaffoldSample/global.json index d76e72f..1cc381b 100644 --- a/WebApiScaffoldSample/global.json +++ b/WebApiScaffoldSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/WebApiScaffoldSample/src/WebApiScaffoldSample/Controllers/ValuesController.cs b/WebApiScaffoldSample/src/WebApiScaffoldSample/Controllers/ValuesController.cs index a993a66..176b600 100644 --- a/WebApiScaffoldSample/src/WebApiScaffoldSample/Controllers/ValuesController.cs +++ b/WebApiScaffoldSample/src/WebApiScaffoldSample/Controllers/ValuesController.cs @@ -4,30 +4,30 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using WebApiSample.Models; using Microsoft.EntityFrameworkCore; +using WebApiSample.Models; -namespace WebApiSample.Controllers +namespace WebApiScaffoldSample.Controllers { - [Produces("application/json")] [Route("api/[controller]")] - public class ValuesController : Controller + [ApiController] + public class ValuesController : ControllerBase { - private readonly SQLiteDbContext _dbContext; + private readonly SQLiteDbContext _context; - public ValuesController(SQLiteDbContext dbContext) + public ValuesController(SQLiteDbContext context) { - _dbContext = dbContext; + _context = context; } - // GET api/values + // GET: api/Values [HttpGet] public IEnumerable GetValues() { - return _dbContext.Values; + return _context.Values; } - // GET api/values/5 + // GET: api/Values/5 [HttpGet("{id}")] public async Task GetValue([FromRoute] int id) { @@ -36,7 +36,7 @@ public async Task GetValue([FromRoute] int id) return BadRequest(ModelState); } - Value value = await _dbContext.Values.SingleOrDefaultAsync(m => m.Id == id); + var value = await _context.Values.FindAsync(id); if (value == null) { @@ -46,38 +46,9 @@ public async Task GetValue([FromRoute] int id) return Ok(value); } - // POST api/values - [HttpPost] - public async Task PostValue([FromBody]Value value) - { - if (!ModelState.IsValid) - { - return BadRequest(ModelState); - } - - _dbContext.Values.Add(value); - try - { - await _dbContext.SaveChangesAsync(); - } - catch (DbUpdateException) - { - if (ValueExists(value.Id)) - { - return new StatusCodeResult(StatusCodes.Status409Conflict); - } - else - { - throw; - } - } - - return CreatedAtAction("GetValue", new { id = value.Id }, value); - } - - // PUT api/values/5 + // PUT: api/Values/5 [HttpPut("{id}")] - public async Task PutValue([FromRoute]int id, [FromBody]Value value) + public async Task PutValue([FromRoute] int id, [FromBody] Value value) { if (!ModelState.IsValid) { @@ -89,11 +60,11 @@ public async Task PutValue([FromRoute]int id, [FromBody]Value val return BadRequest(); } - _dbContext.Entry(value).State = EntityState.Modified; + _context.Entry(value).State = EntityState.Modified; try { - await _dbContext.SaveChangesAsync(); + await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { @@ -110,31 +81,45 @@ public async Task PutValue([FromRoute]int id, [FromBody]Value val return NoContent(); } + // POST: api/Values + [HttpPost] + public async Task PostValue([FromBody] Value value) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.Values.Add(value); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetValue", new { id = value.Id }, value); + } - // DELETE api/values/5 + // DELETE: api/Values/5 [HttpDelete("{id}")] - public async Task DeleteValue([FromRoute]int id) + public async Task DeleteValue([FromRoute] int id) { if (!ModelState.IsValid) { return BadRequest(ModelState); } - Value value = await _dbContext.Values.SingleOrDefaultAsync(m => m.Id == id); + var value = await _context.Values.FindAsync(id); if (value == null) { return NotFound(); } - _dbContext.Values.Remove(value); - await _dbContext.SaveChangesAsync(); + _context.Values.Remove(value); + await _context.SaveChangesAsync(); return Ok(value); } private bool ValueExists(int id) { - return _dbContext.Values.Any(e => e.Id == id); + return _context.Values.Any(e => e.Id == id); } } -} +} \ No newline at end of file diff --git a/WebApiScaffoldSample/src/WebApiScaffoldSample/Program.cs b/WebApiScaffoldSample/src/WebApiScaffoldSample/Program.cs index da94e49..bf5739e 100644 --- a/WebApiScaffoldSample/src/WebApiScaffoldSample/Program.cs +++ b/WebApiScaffoldSample/src/WebApiScaffoldSample/Program.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; namespace WebApiSample { @@ -12,14 +8,11 @@ public class Program { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .Build(); - - host.Run(); + CreateWebHostBuilder(args).Build().Run(); } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); } } diff --git a/WebApiScaffoldSample/src/WebApiScaffoldSample/WebApiScaffoldSample.csproj b/WebApiScaffoldSample/src/WebApiScaffoldSample/WebApiScaffoldSample.csproj index e6f92de..22a323e 100644 --- a/WebApiScaffoldSample/src/WebApiScaffoldSample/WebApiScaffoldSample.csproj +++ b/WebApiScaffoldSample/src/WebApiScaffoldSample/WebApiScaffoldSample.csproj @@ -1,13 +1,13 @@  - netcoreapp1.1 + netcoreapp2.1 true WebApiScaffoldSample Exe WebApiScaffoldSample - 1.1.2 - $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + 2.1.0 + $(PackageTargetFallback) @@ -15,58 +15,15 @@ - - - - - - - - - - - + - - - - - - - - - All - - - - - - All - - + + - - All - - - All - - - All - - - All - - - + diff --git a/WebAppScaffoldSample/global.json b/WebAppScaffoldSample/global.json index d76e72f..1cc381b 100644 --- a/WebAppScaffoldSample/global.json +++ b/WebAppScaffoldSample/global.json @@ -1,6 +1,6 @@ { "projects": [ "src" ], "sdk": { - "version": "1.1.0" + "version": "2.1.300" } } \ No newline at end of file diff --git a/WebAppScaffoldSample/src/WebApplication/.bowerrc b/WebAppScaffoldSample/src/WebApplication/.bowerrc index 6406626..46ac6f5 100644 --- a/WebAppScaffoldSample/src/WebApplication/.bowerrc +++ b/WebAppScaffoldSample/src/WebApplication/.bowerrc @@ -1,3 +1,4 @@ { - "directory": "wwwroot/lib" + "directory": "wwwroot/lib", + "registry": "https://registry.bower.io" } diff --git a/WebAppScaffoldSample/src/WebApplication/Startup.cs b/WebAppScaffoldSample/src/WebApplication/Startup.cs index 6ff8653..d0d902e 100644 --- a/WebAppScaffoldSample/src/WebApplication/Startup.cs +++ b/WebAppScaffoldSample/src/WebApplication/Startup.cs @@ -47,11 +47,12 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); - app.UseBrowserLink(); + //app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); } app.UseStaticFiles(); diff --git a/WebAppScaffoldSample/src/WebApplication/WebApplication.csproj b/WebAppScaffoldSample/src/WebApplication/WebApplication.csproj index 1a6dcda..4bc2f2b 100644 --- a/WebAppScaffoldSample/src/WebApplication/WebApplication.csproj +++ b/WebAppScaffoldSample/src/WebApplication/WebApplication.csproj @@ -1,13 +1,13 @@  - netcoreapp1.1 + netcoreapp2.1 true WebApplication Exe WebApplication - 1.1.2 - $(PackageTargetFallback);portable-net45+win8+wp8+wpa81; + 2.1.0 + $(PackageTargetFallback) @@ -17,38 +17,9 @@ - - - - - - - - - - - - - - - - - - - All - - - - All - - - - All - + + + @@ -60,10 +31,7 @@ - - - All - + diff --git a/WebAppScaffoldSample/src/WebApplication/appsettings.json b/WebAppScaffoldSample/src/WebApplication/appsettings.json index 25da1f3..db22985 100644 --- a/WebAppScaffoldSample/src/WebApplication/appsettings.json +++ b/WebAppScaffoldSample/src/WebApplication/appsettings.json @@ -1,7 +1,7 @@ { "Data": { "DefaultConnection": { - "ConnectionString": "Data Source=..\\..\\..\\db.sqlite" + "ConnectionString": "Data Source=db.sqlite" } }, "Logging": { diff --git a/cakebuild/build.cake b/cakebuild/build.cake index 82480ee..60e4d4b 100644 --- a/cakebuild/build.cake +++ b/cakebuild/build.cake @@ -9,7 +9,7 @@ var buildArtifacts = Directory("./artifacts/packages"); var isAppVeyor = AppVeyor.IsRunningOnAppVeyor; var isWindows = IsRunningOnWindows(); -var netcore = "netcoreapp2.0"; +var netcore = "netcoreapp2.1"; var netstandard = "netstandard2.0"; /////////////////////////////////////////////////////////////////////////////// diff --git a/cakebuild/global.json b/cakebuild/global.json index 5d5d3a7..386035d 100644 --- a/cakebuild/global.json +++ b/cakebuild/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.2" + "version": "2.1.300" } } \ No newline at end of file diff --git a/cakebuild/test/Sample.Tests/Sample.Tests.csproj b/cakebuild/test/Sample.Tests/Sample.Tests.csproj index 8dfac07..7d65af8 100644 --- a/cakebuild/test/Sample.Tests/Sample.Tests.csproj +++ b/cakebuild/test/Sample.Tests/Sample.Tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.1 portable Sample.Tests Sample.Tests diff --git a/console/global.json b/console/global.json index 5d5d3a7..386035d 100644 --- a/console/global.json +++ b/console/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.2" + "version": "2.1.300" } } \ No newline at end of file diff --git a/console/src/src.csproj b/console/src/src.csproj index ce86ae9..dc06528 100644 --- a/console/src/src.csproj +++ b/console/src/src.csproj @@ -1,13 +1,13 @@  - netcoreapp2.0 + netcoreapp2.1 portable src Exe src $(PackageTargetFallback) - 2.0.0 + 2.1.0 @@ -15,7 +15,7 @@ win10-x64 - + diff --git a/ef/global.json b/ef/global.json index 5d5d3a7..386035d 100644 --- a/ef/global.json +++ b/ef/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.2" + "version": "2.1.300" } } \ No newline at end of file diff --git a/ef/src/Program.cs b/ef/src/Program.cs index 73f9faa..35b5230 100644 --- a/ef/src/Program.cs +++ b/ef/src/Program.cs @@ -91,7 +91,7 @@ public static void Main(string[] args) //EnsureSeedData(serviceScope.ServiceProvider.GetService()); } } - + /* public static void EnsureDatabaseCreated() { var optionsBuilder = new DbContextOptionsBuilder(); @@ -107,5 +107,6 @@ public static void EnsureDatabaseCreated() else if (HostingEnvironment.IsProduction()) optionsBuilder.UseSqlServer(Configuration["Data:live:TransientContext"]); new CoreExampleContext(optionsBuilder.Options).Database.EnsureCreated(); } + */ } } diff --git a/ef/src/src.csproj b/ef/src/src.csproj index 3b5f704..c03bfee 100644 --- a/ef/src/src.csproj +++ b/ef/src/src.csproj @@ -1,36 +1,21 @@ - + - netcoreapp2.0 + netcoreapp2.1 portable - src + ef Exe - src + ef $(PackageTargetFallback); win7-x86;win10-x64;osx.10.11-x64;ubuntu.16.04-x64 - 2.0.0 + 2.1.0 - - - - - - - - - - - - - - - - - - - + + + + diff --git a/scaffold/global.json b/scaffold/global.json index 5d5d3a7..386035d 100644 --- a/scaffold/global.json +++ b/scaffold/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.0.2" + "version": "2.1.300" } } \ No newline at end of file diff --git a/scaffold/src/src.csproj b/scaffold/src/src.csproj index 8a65e83..4f49eda 100644 --- a/scaffold/src/src.csproj +++ b/scaffold/src/src.csproj @@ -1,25 +1,20 @@  - netcoreapp2.0 + netcoreapp2.1 portable true src Exe src true - 2.0.0 + 2.1.0 $(PackageTargetFallback); - - - - - - - + + From 786d2523ee7055d80a29411dc3189a481e9ec5b5 Mon Sep 17 00:00:00 2001 From: f7Q Date: Sun, 29 Jul 2018 18:03:38 +0900 Subject: [PATCH 4/4] add MariaDB. --- .../WebApiSample/Models/SampleDbContext.cs | 6 +++++- WebApiSample/src/WebApiSample/Startup.cs | 21 +++++++++++++++++-- .../src/WebApiSample/WebApiSample.csproj | 1 + .../src/WebApiSample/appsettings.json | 6 +++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/WebApiSample/src/WebApiSample/Models/SampleDbContext.cs b/WebApiSample/src/WebApiSample/Models/SampleDbContext.cs index 1c8ad01..3babae2 100644 --- a/WebApiSample/src/WebApiSample/Models/SampleDbContext.cs +++ b/WebApiSample/src/WebApiSample/Models/SampleDbContext.cs @@ -25,7 +25,11 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) .Build(); var dbkind = config["Data:DefaultConnection:ConnectionDBString"]; - if(dbkind.Equals("sqlite")) + if (dbkind.Equals("mysql")) + { + optionsBuilder.UseMySql(config["Data:DefaultConnection:ConnectionString"]); + } + if (dbkind.Equals("sqlite")) { optionsBuilder.UseSqlite(config["Data:DefaultConnection:ConnectionString"]); } diff --git a/WebApiSample/src/WebApiSample/Startup.cs b/WebApiSample/src/WebApiSample/Startup.cs index 8a5dd2c..14dbc13 100644 --- a/WebApiSample/src/WebApiSample/Startup.cs +++ b/WebApiSample/src/WebApiSample/Startup.cs @@ -36,6 +36,14 @@ public void ConfigureServices(IServiceCollection services) services.AddLogging(); var dbkind = Configuration["Data:DefaultConnection:ConnectionDBString"]; + if (dbkind.Equals("mysql")) + { + services.AddEntityFrameworkMySql(); + services.AddDbContext(options => + { + options.UseMySql(Configuration["Data:DefaultConnection:ConnectionString"]); + }); + } if(dbkind.Equals("sqlite")) { services.AddEntityFrameworkSqlite(); @@ -65,7 +73,7 @@ public void ConfigureServices(IServiceCollection services) services.AddEntityFrameworkInMemoryDatabase(); services.AddDbContext(options => { - options.UseInMemoryDatabase(); + options.UseInMemoryDatabase(Guid.NewGuid().ToString()); }); } // Add framework services. @@ -94,7 +102,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF { //loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); - + InitDatabse(app); app.UseMvc(); app.UseSwagger(c => @@ -106,5 +114,14 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF c.SwaggerEndpoint("/api-docs/v1/swagger.json", "My API V1"); }); } + + private void InitDatabse(IApplicationBuilder app) + { + using (var serviceScope = app.ApplicationServices.GetRequiredService().CreateScope()) + { + var context = serviceScope.ServiceProvider.GetService(); + context.Database.EnsureCreated(); + } + } } } diff --git a/WebApiSample/src/WebApiSample/WebApiSample.csproj b/WebApiSample/src/WebApiSample/WebApiSample.csproj index 7a8fc07..4e62cbf 100644 --- a/WebApiSample/src/WebApiSample/WebApiSample.csproj +++ b/WebApiSample/src/WebApiSample/WebApiSample.csproj @@ -15,6 +15,7 @@ + diff --git a/WebApiSample/src/WebApiSample/appsettings.json b/WebApiSample/src/WebApiSample/appsettings.json index db70b74..5e20b9c 100644 --- a/WebApiSample/src/WebApiSample/appsettings.json +++ b/WebApiSample/src/WebApiSample/appsettings.json @@ -2,9 +2,13 @@ "Data": { "DefaultConnection": { "ConnectionDBString": "sqlite", - "ConnectionString": "Data Source=..\\..\\..\\db.sqlite" + "ConnectionString": "Data Source=db.sqlite" } /* + "DefaultConnection": { + "ConnectionDBString": "mysql", + "ConnectionString": "Server=localhost;User Id=root;Password=root;Database=mariadbtest" + } "DefaultConnection": { "ConnectionDBString": "inmemory", "ConnectionString": ""