From d7fdd1fe586194a5d7b8cebbf3f6798ef28711d6 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:25:18 +0800 Subject: [PATCH 01/23] Added appsettings.local.json to ignore file This file can be used to override local settings like the connection string. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c99ff6a..11181a0 100644 --- a/.gitignore +++ b/.gitignore @@ -296,4 +296,5 @@ __pycache__/ *.btp.cs *.btm.cs *.odx.cs -*.xsd.cs \ No newline at end of file +*.xsd.cs +sample/MongoIdentitySample.Mvc/appsettings.local.json From d078e256c899c5554d459188c051dc8f5779dede Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:25:31 +0800 Subject: [PATCH 02/23] remove comments from json file --- sample/MongoIdentitySample.Mvc/bundleconfig.json | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sample/MongoIdentitySample.Mvc/bundleconfig.json b/sample/MongoIdentitySample.Mvc/bundleconfig.json index 6d3f9a5..9d8ef2a 100644 --- a/sample/MongoIdentitySample.Mvc/bundleconfig.json +++ b/sample/MongoIdentitySample.Mvc/bundleconfig.json @@ -1,9 +1,6 @@ -// Configure bundling and minification for the project. -// More info at https://go.microsoft.com/fwlink/?LinkId=808241 -[ - { +[ +{ "outputFileName": "wwwroot/css/site.min.css", - // An array of relative input file paths. Globbing patterns supported "inputFiles": [ "wwwroot/css/site.css" ] @@ -13,12 +10,10 @@ "inputFiles": [ "wwwroot/js/site.js" ], - // Optionally specify minification options "minify": { "enabled": true, "renameLocals": true }, - // Optionally generate .map file "sourceMap": false } ] From b58edfadfc7b932507cd2f476f6a0987f997f894 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:25:51 +0800 Subject: [PATCH 03/23] remove the AspNetCore assemblies as these are no longer needed --- .../MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj b/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj index d682972..fa747cb 100644 --- a/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj +++ b/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj @@ -3,24 +3,23 @@ netcoreapp3.1 aspnet-MongoIdentitySample.Mvc-95B15D82-54F6-4001-B4B0-6ADF4B1BB00E + InProcess - - - - + + From 59213089eda7e0d4173916ad69e84c88da3c456a Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:30:34 +0800 Subject: [PATCH 04/23] Migrated main to 3.1 format --- sample/MongoIdentitySample.Mvc/Program.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sample/MongoIdentitySample.Mvc/Program.cs b/sample/MongoIdentitySample.Mvc/Program.cs index b0fa25a..0d4d7a4 100644 --- a/sample/MongoIdentitySample.Mvc/Program.cs +++ b/sample/MongoIdentitySample.Mvc/Program.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; namespace MongoIdentitySample.Mvc { @@ -11,15 +12,14 @@ namespace MongoIdentitySample.Mvc { public static void Main(string[] args) { - var host = new WebHostBuilder() - .UseKestrel() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseIISIntegration() - .UseStartup() - .UseApplicationInsights() - .Build(); - - host.Run(); + CreateHostBuilder(args).Build().Run(); } + + protected static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); } } From 811d543d357ff9d47ce14638298551b9537e43b5 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:42:50 +0800 Subject: [PATCH 05/23] Changed IHostingEnvironment to IWebHostEnvironment Added insights telemetry to configure services Added local settings json for storing localised settings --- sample/MongoIdentitySample.Mvc/Startup.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sample/MongoIdentitySample.Mvc/Startup.cs b/sample/MongoIdentitySample.Mvc/Startup.cs index 6583063..1f00e92 100644 --- a/sample/MongoIdentitySample.Mvc/Startup.cs +++ b/sample/MongoIdentitySample.Mvc/Startup.cs @@ -9,17 +9,20 @@ using MongoIdentitySample.Mvc.Services; using AspNetCore.Identity.MongoDbCore.Models; using Microsoft.AspNetCore.Identity; using AspNetCore.Identity.MongoDbCore.Infrastructure; +using Microsoft.Extensions.Hosting; namespace MongoIdentitySample.Mvc { public class Startup { - public Startup(IHostingEnvironment env) + public Startup(IWebHostEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + //per user config that is not committed to repo, use this to override settings (e.g. connection string) based on your local environment. + .AddJsonFile($"appsettings.local.json", optional: true); if (env.IsDevelopment()) { @@ -47,13 +50,15 @@ namespace MongoIdentitySample.Mvc services.AddMvc(); + services.AddApplicationInsightsTelemetry(); + // Add application services. services.AddTransient(); services.AddTransient(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) //, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) //, ILoggerFactory loggerFactory) { //loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddDebug(); @@ -75,13 +80,6 @@ namespace MongoIdentitySample.Mvc app.UseAuthorization(); // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715 - //app.UseMvc(routes => - //{ - // routes.MapRoute( - // name: "default", - // template: "{controller=Home}/{action=Index}/{id?}"); - //}); - app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); From 41ea9aac8fad0e1afd7b7cc87426650c0fe1998e Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 09:43:04 +0800 Subject: [PATCH 06/23] add vs code launch settings --- .../.vscode/launch.json | 36 ++++++++++++++++ .../.vscode/tasks.json | 42 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 sample/MongoIdentitySample.Mvc/.vscode/launch.json create mode 100644 sample/MongoIdentitySample.Mvc/.vscode/tasks.json diff --git a/sample/MongoIdentitySample.Mvc/.vscode/launch.json b/sample/MongoIdentitySample.Mvc/.vscode/launch.json new file mode 100644 index 0000000..4a5fbb6 --- /dev/null +++ b/sample/MongoIdentitySample.Mvc/.vscode/launch.json @@ -0,0 +1,36 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/MongoIdentitySample.Mvc.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/sample/MongoIdentitySample.Mvc/.vscode/tasks.json b/sample/MongoIdentitySample.Mvc/.vscode/tasks.json new file mode 100644 index 0000000..5a3c47b --- /dev/null +++ b/sample/MongoIdentitySample.Mvc/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file From c59d7017f8396584e24a2c4c3b5cf888ea50b3e2 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 10:22:39 +0800 Subject: [PATCH 07/23] added launch for VS Code --- .vscode/launch.json | 34 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..43ad75d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,34 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/sample/MongoIdentitySample.Mvc/bin/Debug/netcoreapp3.1/MongoIdentitySample.Mvc.dll", + "args": [], + "cwd": "${workspaceFolder}/sample/MongoIdentitySample.Mvc", + "stopAtEntry": false, + "serverReadyAction": { + "action": "openExternally", + "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..171633c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,42 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "${workspaceFolder}/sample/MongoIdentitySample.Mvc/MongoIdentitySample.Mvc.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file From f1265ec3dfd9803b258d05babfb259b400c691f1 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 10:32:54 +0800 Subject: [PATCH 08/23] add razor runtime compilation for development environment --- sample/MongoIdentitySample.Mvc/Startup.cs | 14 +++++++++++++- .../Views/Shared/_Layout.cshtml | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sample/MongoIdentitySample.Mvc/Startup.cs b/sample/MongoIdentitySample.Mvc/Startup.cs index 48cbab4..cbf26a8 100644 --- a/sample/MongoIdentitySample.Mvc/Startup.cs +++ b/sample/MongoIdentitySample.Mvc/Startup.cs @@ -15,8 +15,10 @@ namespace MongoIdentitySample.Mvc { public class Startup { + private IWebHostEnvironment _env; public Startup(IWebHostEnvironment env) { + _env = env; var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) @@ -38,12 +40,22 @@ namespace MongoIdentitySample.Mvc var settings = Configuration.GetSection(nameof(MongoDbSettings)).Get(); services.AddSingleton(settings); - + services.AddIdentity() .AddMongoDbStores(settings.ConnectionString, settings.DatabaseName) .AddSignInManager() .AddDefaultTokenProviders(); + + var builder = services.AddRazorPages(); + + #if DEBUG + if(_env.IsDevelopment()) + { + builder.AddRazorRuntimeCompilation(); + } + #endif + services.AddMvc(); services.AddApplicationInsightsTelemetry(); diff --git a/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml b/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml index 15c0be6..8cbfd77 100644 --- a/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml +++ b/sample/MongoIdentitySample.Mvc/Views/Shared/_Layout.cshtml @@ -31,7 +31,7 @@ @RenderBody()
-

© 2016 - IdentitySample

+

© 2020 - IdentitySample

From 80b35e3baf26107b8e4278518f767d86fc2b62f2 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 12:57:51 +0800 Subject: [PATCH 09/23] Add appsettings config load for tests Enables the config to be changed outside of the test appsettings.local.json is not checked into the repo --- .gitignore | 1 + ...entity.MongoDbCore.IntegrationTests.csproj | 5 ++ .../Infrastructure/Container.cs | 79 +++++++++++++------ .../appsettings.json | 12 +++ 4 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json diff --git a/.gitignore b/.gitignore index 11181a0..827bbf5 100644 --- a/.gitignore +++ b/.gitignore @@ -298,3 +298,4 @@ __pycache__/ *.odx.cs *.xsd.cs sample/MongoIdentitySample.Mvc/appsettings.local.json +test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.local.json diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj index 44f31f6..2ab4ae9 100644 --- a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj +++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj @@ -33,4 +33,9 @@
+ + + Always + + diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs index c2e3de0..523ec3d 100644 --- a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs +++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs @@ -1,5 +1,6 @@ using AspNetCore.Identity.MongoDbCore.Extensions; using AspNetCore.Identity.MongoDbCore.Infrastructure; +using Microsoft.Extensions.Configuration; using System; namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure @@ -12,22 +13,47 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure public static class Container { - public static MongoDbIdentityConfiguration MongoDbIdentityConfiguration = new MongoDbIdentityConfiguration + public static IConfiguration Configuration { get; set; } + + static Container() { - MongoDbSettings = new MongoDbSettings + var builder = new ConfigurationBuilder() + .SetBasePath(System.Environment.CurrentDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + //per user config that is not committed to repo, use this to override settings (e.g. connection string) based on your local environment. + .AddJsonFile($"appsettings.local.json", optional: true); + + //builder.AddEnvironmentVariables(); + + Configuration = builder.Build(); + + var databaseSettings = Configuration.Load("MongoDbSettings"); + + MongoDbIdentityConfiguration = new MongoDbIdentityConfiguration() { - ConnectionString = "mongodb://localhost:27017", - DatabaseName = "MongoDbTests" - }, - IdentityOptionsAction = options => + MongoDbSettings = databaseSettings, + IdentityOptionsAction = (options) => + { + options.Password.RequireDigit = false; + options.Password.RequireLowercase = false; + options.Password.RequireNonAlphanumeric = false; + options.Password.RequireUppercase = false; + options.User.AllowedUserNameCharacters = null; + } + }; + + lock (Locks.MongoInitLock) { - options.Password.RequireDigit = false; - options.Password.RequireLowercase = false; - options.Password.RequireNonAlphanumeric = false; - options.Password.RequireUppercase = false; - options.User.AllowedUserNameCharacters = null; + _mongoDbRepository = new MongoRepository( + databaseSettings.ConnectionString, + databaseSettings.DatabaseName); + _mongoDbRepository2 = new MongoRepository( + databaseSettings.ConnectionString, + databaseSettings.DatabaseName); } - }; + } + + public static MongoDbIdentityConfiguration MongoDbIdentityConfiguration { get; set; } public static IServiceProvider Instance { get; set; } @@ -36,19 +62,6 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure private static readonly IMongoRepository _mongoDbRepository2; - static Container() - { - lock (Locks.MongoInitLock) - { - _mongoDbRepository = new MongoRepository( - MongoDbIdentityConfiguration.MongoDbSettings.ConnectionString, - MongoDbIdentityConfiguration.MongoDbSettings.DatabaseName); - _mongoDbRepository2 = new MongoRepository( - MongoDbIdentityConfiguration.MongoDbSettings.ConnectionString, - MongoDbIdentityConfiguration.MongoDbSettings.DatabaseName); - } - } - public static IMongoRepository MongoRepository { get @@ -65,4 +78,20 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure } } } + + public static class ConfigurationExtensions + { + public static T Load(this IConfiguration configuration, string key) where T : new() + { + var instance = new T(); + configuration.GetSection(key).Bind(instance); + return instance; + } + + public static T Load(this IConfiguration configuration, string key, T instance) where T : new() + { + configuration.GetSection(key).Bind(instance); + return instance; + } + } } diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json new file mode 100644 index 0000000..5c53f25 --- /dev/null +++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/appsettings.json @@ -0,0 +1,12 @@ +{ + "MongoDbSettings": { + "ConnectionString": "mongodb://localhost:27017", + "DatabaseName": "MongoDbTests" + }, + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning" + } + } +} From 02c6a1c934fbd8bc4d43d50496c7ff26f672dab7 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 12:58:47 +0800 Subject: [PATCH 10/23] Update nuspec package for CI/CD Added package.ps1 file for building, testing and packaging the library --- package.ps1 | 10 ++++++++++ src/AspNetCore.Identity.MongoDbCore.nuspec | 22 +++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 package.ps1 diff --git a/package.ps1 b/package.ps1 new file mode 100644 index 0000000..6c6c44e --- /dev/null +++ b/package.ps1 @@ -0,0 +1,10 @@ + +$project="./src/AspNetCore.Identity.MongoDbCore.csproj" +$testProject="./test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj" +$configuration="Release" +$nuspecFile="AspnetCore.Identity.MongoDbCore.nuspec" +$output="./nuget" + +dotnet build +dotnet test $testProject +dotnet pack --no-restore --no-build $project --configuration $configuration -p:NuspecFile=$nuspecFile -o $output \ No newline at end of file diff --git a/src/AspNetCore.Identity.MongoDbCore.nuspec b/src/AspNetCore.Identity.MongoDbCore.nuspec index 91c296c..63916fc 100644 --- a/src/AspNetCore.Identity.MongoDbCore.nuspec +++ b/src/AspNetCore.Identity.MongoDbCore.nuspec @@ -2,11 +2,11 @@ AspNetCore.Identity.MongoDbCore - 1.1.1 + 2.1.0 AspNetCore.Identity.MongoDbCore Alexandre Spieser Alexandre Spieser - http://www.opensource.org/licenses/mit-license.php + MIT https://github.com/alexandre-spieser/AspNetCore.Identity.MongoDbCore false A MongoDb UserStore and RoleStore adapter for Microsoft.AspNetCore.Identity 2.0. @@ -14,13 +14,21 @@ Copyright 2018 (c) Alexandre Spieser. All rights reserved. aspnetcore mongo mongodb identity membership - - - - + + + + + + + + + + + + - + \ No newline at end of file From b159af4e72701e3aa854d37da28480a524914285 Mon Sep 17 00:00:00 2001 From: David Barker Date: Fri, 24 Jan 2020 12:59:04 +0800 Subject: [PATCH 11/23] Added environment variables to the configuration load --- .../Infrastructure/Container.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs index 523ec3d..7ba989d 100644 --- a/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs +++ b/test/AspNetCore.Identity.MongoDbCore.IntegrationTests/Infrastructure/Container.cs @@ -23,7 +23,7 @@ namespace AspNetCore.Identity.MongoDbCore.IntegrationTests.Infrastructure //per user config that is not committed to repo, use this to override settings (e.g. connection string) based on your local environment. .AddJsonFile($"appsettings.local.json", optional: true); - //builder.AddEnvironmentVariables(); + builder.AddEnvironmentVariables(); Configuration = builder.Build(); From 6bb122f49700c86df9a6fcda96d6c840ce8d7680 Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 14:13:46 +0800 Subject: [PATCH 12/23] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..3e204d8 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,50 @@ +# ASP.NET Core (.NET Framework) +# Build and test ASP.NET Core projects targeting the full .NET Framework. +# Add steps that publish symbols, save build artifacts, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core + +trigger: +- master + +pool: + vmImage: 'windows-latest' + +variables: + solution: '**/*.sln' + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + +steps: +- task: NuGetToolInstaller@1 + +- task: NuGetCommand@2 + inputs: + restoreSolution: '$(solution)' + +- task: DotNetCoreCLI@2 + inputs: + command: 'build' + projects: './src/AspNetCore.Identity.MongoDbCore.csproj' + arguments: '--configuiration $(buildConfiguration)' + +- task: VSTest@2 + inputs: + platform: '$(buildPlatform)' + configuration: '$(buildConfiguration)' + +- task: DotNetCoreCLI@2 + inputs: + command: 'pack' + packagesToPack: './src/AspNetCore.Identity.MongoDbCore.csproj' + versioningScheme: 'off' + arguments: '-p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' + modifyOutputPath: true + packDirectory: $(build.artifactStagingDirectory)/Nuget + +- task: NuGetCommand@2 + inputs: + command: 'push' + packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' + nuGetFeedType: 'internal' + publishVstsFeed: '72ef5435-c019-4338-8d35-7c3caec78f2a' + verbosityPush: 'Normal' \ No newline at end of file From d5d834685790f3ac89aa47e65ddb7ff88100b3d3 Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 14:27:25 +0800 Subject: [PATCH 13/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3e204d8..8134c93 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -25,7 +25,7 @@ steps: inputs: command: 'build' projects: './src/AspNetCore.Identity.MongoDbCore.csproj' - arguments: '--configuiration $(buildConfiguration)' + arguments: '--configuration $(buildConfiguration)' - task: VSTest@2 inputs: @@ -37,7 +37,7 @@ steps: command: 'pack' packagesToPack: './src/AspNetCore.Identity.MongoDbCore.csproj' versioningScheme: 'off' - arguments: '-p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' + arguments: '--configuration $(buildConfiguration) -p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' modifyOutputPath: true packDirectory: $(build.artifactStagingDirectory)/Nuget From 4ed2e6f6ec2e264057b3a7ecc937323de327ab7e Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 15:20:37 +0800 Subject: [PATCH 14/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8134c93..f3d1639 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,19 +27,20 @@ steps: projects: './src/AspNetCore.Identity.MongoDbCore.csproj' arguments: '--configuration $(buildConfiguration)' -- task: VSTest@2 +- task: DotNetCoreCLI@2 inputs: - platform: '$(buildPlatform)' - configuration: '$(buildConfiguration)' + command: 'build' + projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj' + arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 inputs: command: 'pack' - packagesToPack: './src/AspNetCore.Identity.MongoDbCore.csproj' + packagesToPack: './src/AspnetCore.Identity.MongoDbCore.nuspec' versioningScheme: 'off' - arguments: '--configuration $(buildConfiguration) -p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' modifyOutputPath: true packDirectory: $(build.artifactStagingDirectory)/Nuget + nobuild: true - task: NuGetCommand@2 inputs: From 79f54b212fa36097f50b511f8f0daca4fdfefe8a Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 15:30:54 +0800 Subject: [PATCH 15/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f3d1639..0d2d460 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -36,9 +36,9 @@ steps: - task: DotNetCoreCLI@2 inputs: command: 'pack' - packagesToPack: './src/AspnetCore.Identity.MongoDbCore.nuspec' + packagesToPack: './src/AspnetCore.Identity.MongoDbCore.csproj' versioningScheme: 'off' - modifyOutputPath: true + arguments: '-p:NuspecFile=./src/AspnetCore.Identity.MongoDbCore.nuspec' packDirectory: $(build.artifactStagingDirectory)/Nuget nobuild: true From 57c01c3297efaf8d0f0006c261bfc6baf4f7eddb Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:00:03 +0800 Subject: [PATCH 16/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0d2d460..f20b46a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,7 +7,7 @@ trigger: - master pool: - vmImage: 'windows-latest' + vmImage: 'ubuntu-latest' variables: solution: '**/*.sln' @@ -29,7 +29,7 @@ steps: - task: DotNetCoreCLI@2 inputs: - command: 'build' + command: 'test' projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj' arguments: '--configuration $(buildConfiguration)' @@ -41,6 +41,15 @@ steps: arguments: '-p:NuspecFile=./src/AspnetCore.Identity.MongoDbCore.nuspec' packDirectory: $(build.artifactStagingDirectory)/Nuget nobuild: true + verbosityPack: 'Minimal' + +- task: DotNetCoreCLI@2 + inputs: + command: 'pack' + packagesToPack: '**/*.csproj' + nobuild: true + versioningScheme: 'off' + verbosityPack: 'Minimal' - task: NuGetCommand@2 inputs: From fbc039f73a16dd2ddb51ec64b2608a9b962c250d Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:03:37 +0800 Subject: [PATCH 17/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f20b46a..5538b81 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,6 +15,12 @@ variables: buildConfiguration: 'Release' steps: + +- task: UseDotNet@2 + inputs: + packageType: 'sdk' + version: '3.1.101' + - task: NuGetToolInstaller@1 - task: NuGetCommand@2 From 236bfb3cdce886f81bb8918cbb5190a941c7483b Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:06:31 +0800 Subject: [PATCH 18/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5538b81..d6d354b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,6 +17,7 @@ variables: steps: - task: UseDotNet@2 + displayName: 'Install .net core 3.1' inputs: packageType: 'sdk' version: '3.1.101' @@ -24,22 +25,26 @@ steps: - task: NuGetToolInstaller@1 - task: NuGetCommand@2 + displayName: 'Restore Library Dependencies' inputs: restoreSolution: '$(solution)' - task: DotNetCoreCLI@2 + displayName: 'Build Library' inputs: command: 'build' projects: './src/AspNetCore.Identity.MongoDbCore.csproj' arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 + displayName: 'Test Library' inputs: command: 'test' projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj' arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 + displayName: 'Package Library' inputs: command: 'pack' packagesToPack: './src/AspnetCore.Identity.MongoDbCore.csproj' @@ -49,15 +54,8 @@ steps: nobuild: true verbosityPack: 'Minimal' -- task: DotNetCoreCLI@2 - inputs: - command: 'pack' - packagesToPack: '**/*.csproj' - nobuild: true - versioningScheme: 'off' - verbosityPack: 'Minimal' - - task: NuGetCommand@2 + displayName: 'Publish Library' inputs: command: 'push' packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' From b5365249d9b264842a905aad83b9ab02380d9343 Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:09:32 +0800 Subject: [PATCH 19/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d6d354b..31bcbc4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -36,12 +36,12 @@ steps: projects: './src/AspNetCore.Identity.MongoDbCore.csproj' arguments: '--configuration $(buildConfiguration)' -- task: DotNetCoreCLI@2 - displayName: 'Test Library' - inputs: - command: 'test' - projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj' - arguments: '--configuration $(buildConfiguration)' +# - task: DotNetCoreCLI@2 +# displayName: 'Test Library' +# inputs: +# command: 'test' +# projects: './test/AspNetCore.Identity.MongoDbCore.IntegrationTests/AspNetCore.Identity.MongoDbCore.IntegrationTests.csproj' +# arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 displayName: 'Package Library' From 727b9a8041762116f2ac1f322154fcb8203417ea Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:38:45 +0800 Subject: [PATCH 20/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 31bcbc4..cb3c35b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,10 +49,10 @@ steps: command: 'pack' packagesToPack: './src/AspnetCore.Identity.MongoDbCore.csproj' versioningScheme: 'off' - arguments: '-p:NuspecFile=./src/AspnetCore.Identity.MongoDbCore.nuspec' + arguments: '-p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' packDirectory: $(build.artifactStagingDirectory)/Nuget nobuild: true - verbosityPack: 'Minimal' + verbosityPack: 'Normal' - task: NuGetCommand@2 displayName: 'Publish Library' From 68b5e63b4e1a2a203e3d87e714e7cd9443fdd077 Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:51:04 +0800 Subject: [PATCH 21/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cb3c35b..ecdd19c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -47,12 +47,12 @@ steps: displayName: 'Package Library' inputs: command: 'pack' - packagesToPack: './src/AspnetCore.Identity.MongoDbCore.csproj' + packagesToPack: './src/AspNetCore.Identity.MongoDbCore.csproj' versioningScheme: 'off' arguments: '-p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' packDirectory: $(build.artifactStagingDirectory)/Nuget nobuild: true - verbosityPack: 'Normal' + verbosityPack: 'Detailed' - task: NuGetCommand@2 displayName: 'Publish Library' From 33434bd9651ead208b9aa5efc2b787725cb9ea3c Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 17:10:10 +0800 Subject: [PATCH 22/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ecdd19c..bcad77f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -44,14 +44,11 @@ steps: # arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 - displayName: 'Package Library' inputs: - command: 'pack' - packagesToPack: './src/AspNetCore.Identity.MongoDbCore.csproj' - versioningScheme: 'off' - arguments: '-p:NuspecFile=AspnetCore.Identity.MongoDbCore.nuspec' - packDirectory: $(build.artifactStagingDirectory)/Nuget - nobuild: true + command: 'custom' + projects: './src/AspNetCore.Identity.MongoDbCore.csproj' + custom: 'pack' + arguments: '--no-build -p:NuspecFile=AspNetCore.Identity.MongoDbCore.nuspec -o $(build.artifactStagingDirectory)/Nuget' verbosityPack: 'Detailed' - task: NuGetCommand@2 From c544f0e8e84bc16e1a240a0eeca58480375879ba Mon Sep 17 00:00:00 2001 From: d-barker <31757611+d-barker@users.noreply.github.com> Date: Fri, 24 Jan 2020 17:17:50 +0800 Subject: [PATCH 23/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index bcad77f..e763091 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,7 +1,3 @@ -# ASP.NET Core (.NET Framework) -# Build and test ASP.NET Core projects targeting the full .NET Framework. -# Add steps that publish symbols, save build artifacts, and more: -# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core trigger: - master @@ -44,6 +40,7 @@ steps: # arguments: '--configuration $(buildConfiguration)' - task: DotNetCoreCLI@2 + displayName: 'Package Library (nuget)' inputs: command: 'custom' projects: './src/AspNetCore.Identity.MongoDbCore.csproj'