From 1f7b0f4cf658042f5f214d8248b58f52d6ac6a0a Mon Sep 17 00:00:00 2001 From: pvasek Date: Fri, 10 Jun 2016 16:53:18 +0200 Subject: [PATCH] Commands updated, testing assemblies in progress --- .../AppDbContext.cs | 2 +- ...ds.IntegrationTest.DbContextAssembly.xproj | 2 +- .../Startup.cs | 5 +-- .../project.json | 38 +++++++++++-------- ...ands.IntegrationTest.StartupAssembly.xproj | 2 +- .../project.json | 29 +++++++------- src/DataGenerator.Commands.Tests.sln | 8 +--- .../DataGenerator.Commands.Tests.xproj | 2 +- .../DataGenerator.Commands.xproj | 8 ++-- .../DbDataBootstrapper.cs | 13 ++++--- src/DataGenerator.Commands/Program.cs | 8 ++-- src/DataGenerator.Commands/project.json | 38 ++++++++++--------- 12 files changed, 81 insertions(+), 74 deletions(-) diff --git a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/AppDbContext.cs b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/AppDbContext.cs index 072f308..4855282 100644 --- a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/AppDbContext.cs +++ b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/AppDbContext.cs @@ -1,5 +1,5 @@ using System; -using Microsoft.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace DataGenerator.Commands.IntegrationTest.DbContextAssembly { diff --git a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/DataGenerator.Commands.IntegrationTest.DbContextAssembly.xproj b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/DataGenerator.Commands.IntegrationTest.DbContextAssembly.xproj index 1739155..5e686db 100644 --- a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/DataGenerator.Commands.IntegrationTest.DbContextAssembly.xproj +++ b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/DataGenerator.Commands.IntegrationTest.DbContextAssembly.xproj @@ -9,7 +9,7 @@ ce309050-4a29-4157-b734-2c470ae67d59 DataGenerator.Commands.IntegrationTest.DbContextAssembly ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ 2.0 diff --git a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/Startup.cs b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/Startup.cs index 844ba44..c6237db 100644 --- a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/Startup.cs +++ b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/Startup.cs @@ -1,6 +1,6 @@ using System; using Microsoft.AspNet.Hosting; -using Microsoft.Data.Entity; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; namespace DataGenerator.Commands.IntegrationTest.DbContextAssembly @@ -12,8 +12,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { Console.WriteLine("DataGenerator.Commands.IntegrationTest.DbContextAssembly.Startup.ConfigureServices"); - services.AddEntityFramework() - .AddInMemoryDatabase() + services .AddDbContext(options => { options.UseInMemoryDatabase(); diff --git a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/project.json b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/project.json index dfd85ef..ab04961 100644 --- a/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/project.json +++ b/src/DataGenerator.Commands.IntegrationTest.DbContextAssembly/project.json @@ -2,31 +2,37 @@ "version": "1.0.0-*", "description": "DataGenerator.Commands.IntegrationTest.DbContext Console Application", "authors": [ "pvasek" ], - "tags": [ "" ], - "projectUrl": "", - "licenseUrl": "", - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, - "contentFiles": [ "run.ps1" ], - "dependencies": { - "DataGenerator.Commands": "", - "EntityFramework.InMemory": "7.0.0-rc1-final", - "EntityFramework.Core": "7.0.0-rc1-final", - "Microsoft.AspNet.Hosting": "1.0.0-rc1-final" + "NETStandard.Library": "1.5.0-rc2-24027", + "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final", + "Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-final" }, - "commands": { + "frameworks": { + "net451": { + "buildOptions": { + "outputName": "Microsoft.EntityFrameworkCore.Tools", + "emitEntryPoint": false + } + } + }, + + "tools": { + "DataGenerator.Commands": { + "version": "1.0.0-*" + } + } + + /*"commands": { "datagen1a": "DataGenerator.Commands --mode wait", "datagen2a": "DataGenerator.Commands --mode wait --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator", "datagen2b": "DataGenerator.Commands --mode wait --dbContextAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator", - "datagen2c": "DataGenerator.Commands --mode wait --dbContextAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --startupAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator", - }, + "datagen2c": "DataGenerator.Commands --mode wait --dbContextAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --startupAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator" + }*/ - "frameworks": { - "dnx451": { } - } } diff --git a/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/DataGenerator.Commands.IntegrationTest.StartupAssembly.xproj b/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/DataGenerator.Commands.IntegrationTest.StartupAssembly.xproj index 1997650..143a614 100644 --- a/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/DataGenerator.Commands.IntegrationTest.StartupAssembly.xproj +++ b/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/DataGenerator.Commands.IntegrationTest.StartupAssembly.xproj @@ -9,7 +9,7 @@ cfce529e-9eeb-471f-ba0e-e854636eca97 DataGenerator.Commands.IntegrationTest.StartupAssembly ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ 2.0 diff --git a/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/project.json b/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/project.json index 196711e..0256b42 100644 --- a/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/project.json +++ b/src/DataGenerator.Commands.IntegrationTest.StartupAssembly/project.json @@ -2,26 +2,29 @@ "version": "1.0.0-*", "description": "DataGenerator.Commands.IntegrationTests.StartupAssembly Console Application", "authors": [ "pvasek" ], - "tags": [ "" ], - "projectUrl": "", - "licenseUrl": "", - "compilationOptions": { + "buildOptions": { "emitEntryPoint": true }, "dependencies": { - "DataGenerator.Commands.IntegrationTest.DbContextAssembly": "", - "EntityFramework.InMemory": "7.0.0-rc1-final", - "EntityFramework.Core": "7.0.0-rc1-final", - "Microsoft.AspNet.Hosting": "1.0.0-rc1-final" + "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final", + "Microsoft.EntityFrameworkCore.InMemory": "1.0.0-rc2-final", + "DataGenerator.Commands.IntegrationTest.DbContextAssembly": "" }, - "commands": { - "datagen3a": "DataGenerator.Commands --mode wait --dbContextAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --startupAssembly DataGenerator.Commands.IntegrationTest.StartupAssembly --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator" + "frameworks": { + "net451": { + "buildOptions": { + "outputName": "Microsoft.EntityFrameworkCore.Tools", + "emitEntryPoint": false + } + } }, - "frameworks": { - "dnx451": { } - } + +/* "commands": { + "datagen3a": "DataGenerator.Commands --mode wait --dbContextAssembly DataGenerator.Commands.IntegrationTest.DbContextAssembly --startupAssembly DataGenerator.Commands.IntegrationTest.StartupAssembly --generatorType DataGenerator.Commands.IntegrationTest.DbContextAssembly.DataGenerator" + }*/ + } diff --git a/src/DataGenerator.Commands.Tests.sln b/src/DataGenerator.Commands.Tests.sln index 93d73e7..7aa31bc 100644 --- a/src/DataGenerator.Commands.Tests.sln +++ b/src/DataGenerator.Commands.Tests.sln @@ -1,10 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DataGenerator.Commands.Tests", "DataGenerator.Commands.Tests\DataGenerator.Commands.Tests.xproj", "{0AA3074A-639D-475B-B526-28F924665B3E}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DataGenerator.Commands", "DataGenerator.Commands\DataGenerator.Commands.xproj", "{2203C05A-DED2-40EB-B4EA-54B663EECC9C}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "DataGenerator.Commands.IntegrationTest.DbContextAssembly", "DataGenerator.Commands.IntegrationTest.DbContextAssembly\DataGenerator.Commands.IntegrationTest.DbContextAssembly.xproj", "{CE309050-4A29-4157-B734-2C470AE67D59}" @@ -22,10 +20,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0AA3074A-639D-475B-B526-28F924665B3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0AA3074A-639D-475B-B526-28F924665B3E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0AA3074A-639D-475B-B526-28F924665B3E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0AA3074A-639D-475B-B526-28F924665B3E}.Release|Any CPU.Build.0 = Release|Any CPU {2203C05A-DED2-40EB-B4EA-54B663EECC9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2203C05A-DED2-40EB-B4EA-54B663EECC9C}.Debug|Any CPU.Build.0 = Debug|Any CPU {2203C05A-DED2-40EB-B4EA-54B663EECC9C}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/DataGenerator.Commands.Tests/DataGenerator.Commands.Tests.xproj b/src/DataGenerator.Commands.Tests/DataGenerator.Commands.Tests.xproj index 614e148..d5ad8fa 100644 --- a/src/DataGenerator.Commands.Tests/DataGenerator.Commands.Tests.xproj +++ b/src/DataGenerator.Commands.Tests/DataGenerator.Commands.Tests.xproj @@ -9,7 +9,7 @@ 0aa3074a-639d-475b-b526-28f924665b3e DataGenerator.Commands.Tests ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\bin\ 2.0 diff --git a/src/DataGenerator.Commands/DataGenerator.Commands.xproj b/src/DataGenerator.Commands/DataGenerator.Commands.xproj index c7e4de2..88b098c 100644 --- a/src/DataGenerator.Commands/DataGenerator.Commands.xproj +++ b/src/DataGenerator.Commands/DataGenerator.Commands.xproj @@ -4,12 +4,12 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 2203c05a-ded2-40eb-b4ea-54b663eecc9c DataGenerator.Commands - ..\artifacts\obj\$(MSBuildProjectName) - ..\artifacts\bin\$(MSBuildProjectName)\ + .\obj + .\bin 2.0 @@ -18,5 +18,5 @@ True - + \ No newline at end of file diff --git a/src/DataGenerator.Commands/DbDataBootstrapper.cs b/src/DataGenerator.Commands/DbDataBootstrapper.cs index 1b9d782..b4218ea 100644 --- a/src/DataGenerator.Commands/DbDataBootstrapper.cs +++ b/src/DataGenerator.Commands/DbDataBootstrapper.cs @@ -1,20 +1,21 @@ using System; using System.Reflection; -using Microsoft.Data.Entity.Design; +using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Logging; -using Microsoft.Data.Entity; +using Microsoft.EntityFrameworkCore; namespace DataGenerator.Commands { public class DbDataBootstrapper { - public static bool Bootsrap(DbDataBoostraperOptions options, ILogger logger) + public static bool Bootsrap(DbDataBoostraperOptions options, ILogger logger, string targetDir) { var dbContextOperations = new DbContextOperations( new SimpleLoggerProvider(logger), - options.DbContextAssembly, - options.StartupAssembly, - options.Environment); + Assembly.Load(options.DbContextAssembly), + Assembly.Load(options.StartupAssembly), + options.Environment, + targetDir); logger.LogInformation("Creating db context..."); using (var dbContext = dbContextOperations.CreateContext(null)) diff --git a/src/DataGenerator.Commands/Program.cs b/src/DataGenerator.Commands/Program.cs index bf707cc..3649380 100644 --- a/src/DataGenerator.Commands/Program.cs +++ b/src/DataGenerator.Commands/Program.cs @@ -1,11 +1,10 @@ using System; using System.Linq; -using System.Collections.Generic; using System.Reflection; using Microsoft.Extensions.CommandLineUtils; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Console; using Microsoft.Extensions.PlatformAbstractions; +using System.IO; namespace DataGenerator.Commands { @@ -14,6 +13,7 @@ public class Program public static int Main(string[] args) { + var app = new CommandLineApplication(); app.Name = "DataGenerator.Commands (0.1.2)"; app.Description = "Use existing DbContext in your project for different operations."; @@ -63,7 +63,7 @@ public static int Main(string[] args) var generatorTypeName = generatorType.Value() ?? FindGenerator(generatorAssemblyName); if (generatorTypeName == null) { - logger.LogError($"Cannot find DataGenerator in assembly {generatorAssemblyName}"); + logger.WriteMessage(Microsoft.Extensions.Logging.LogLevel.Error, "datagen", 1, $"Cannot find DataGenerator in assembly {generatorAssemblyName}"); return 1; } @@ -86,7 +86,7 @@ public static int Main(string[] args) } - return DbDataBootstrapper.Bootsrap(options, logger) ? 0 : 2; + return DbDataBootstrapper.Bootsrap(options, logger, Directory.GetCurrentDirectory()) ? 0 : 2; }); var result = app.Execute(args); diff --git a/src/DataGenerator.Commands/project.json b/src/DataGenerator.Commands/project.json index 3bc87d2..24cdb87 100644 --- a/src/DataGenerator.Commands/project.json +++ b/src/DataGenerator.Commands/project.json @@ -1,28 +1,32 @@ { - "version": "0.1.6-*", + "version": "1.0.1-*", "description": "Data generation commmands", "authors": [ "ST-Software" ], - "tags": [ "entity-framework", "net-core", "data-generation" ], - "projectUrl": "https://github.com/ST-Software/DataGenerator.Commands", - "licenseUrl": "https://raw.githubusercontent.com/ST-Software/DataGenerator.Commands/master/LICENSE", - "dependencies": { - "EntityFramework.Commands": "7.0.0-rc1-final", - "Microsoft.Extensions.CommandLineUtils": "1.0.0-rc2-16107", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final" + "packOptions": { + "tags": [ "entity-framework", "net-core", "data-generation" ], + "projectUrl": "https://github.com/ST-Software/DataGenerator.Commands", + "licenseUrl": "https://raw.githubusercontent.com/ST-Software/DataGenerator.Commands/master/LICENSE" + }, + + "buildOptions": { + "emitEntryPoint": true, + "outputName": "dotnet-datagen", + "warningsAsErrors": true }, - "commands": { - "help": "DataGenerator.Commands --help", - "run1": "DataGenerator.Commands --generatorType generator_type", - "run2": "DataGenerator.Commands --dbContextAssembly db_context_assembly --generatorType generator_type --recreate host|db" + "dependencies": { + "Microsoft.EntityFrameworkCore.Design": "1.0.0-*", + "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final", + "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final" }, - "frameworks": { - "dnx451": { - "frameworkAssemblies": { - "System.Runtime": "4.0.10.0" + "frameworks": { + "net451": { + "buildOptions": { + "outputName": "Microsoft.EntityFrameworkCore.Tools", + "emitEntryPoint": false + } } - } } }