From 21b9cfa59a8ae552130676361d0c2218ccb4b958 Mon Sep 17 00:00:00 2001 From: Gary Pretty Date: Wed, 18 Mar 2020 18:10:44 +0000 Subject: [PATCH] Migrate samples to .Net Core 3.1 (#2158) * Migrate samples to .Net Core 3.1. Remove unnecessary usings across solution. Make adapter sample namespaces for consistency. * Update Bot Builder packages to use MyGet 4.8 preview * Update skill samples startupcs / program.cs * Fix missing using statement * Update Bot.Builder preview packages to latest * use onEndOfConversation in JS sample 80 (#2232) * Update NuGet packages to 4.8 RC2 * Updates packages to 4.8.0 and fixed typos Co-authored-by: Steven Gum <14935595+stevengum@users.noreply.github.com> --- .../01.console-echo/Console-EchoBot.csproj | 7 ++-- .../02.echo-bot/EchoBot.csproj | 6 +-- .../csharp_dotnetcore/02.echo-bot/Program.cs | 19 +++++++--- .../csharp_dotnetcore/02.echo-bot/Startup.cs | 26 +++++++------ .../03.welcome-user/Program.cs | 21 +++++----- .../03.welcome-user/Startup.cs | 27 ++++++------- .../03.welcome-user/WelcomeUser.csproj | 6 +-- .../05.multi-turn-prompt/Bots/DialogBot.cs | 2 +- .../Dialogs/UserProfileDialog.cs | 1 - .../MultiTurnPromptBot.csproj | 8 ++-- .../05.multi-turn-prompt/Program.cs | 21 +++++----- .../05.multi-turn-prompt/Startup.cs | 24 ++++++------ .../06.using-cards/Bots/DialogBot.cs | 2 +- .../06.using-cards/CardsBot.csproj | 8 ++-- .../06.using-cards/Program.cs | 21 +++++----- .../06.using-cards/Startup.cs | 24 ++++++------ .../AdaptiveCardsBot.csproj | 8 ++-- .../07.using-adaptive-cards/Program.cs | 21 +++++----- .../07.using-adaptive-cards/Startup.cs | 24 ++++++------ .../Bots/SuggestedActionsBot.cs | 2 - .../08.suggested-actions/Program.cs | 21 +++++----- .../08.suggested-actions/Startup.cs | 24 ++++++------ .../SuggestedActionsBot.csproj | 6 +-- .../csharp_dotnetcore/11.qnamaker/Program.cs | 21 +++++----- .../11.qnamaker/QnABot.csproj | 8 ++-- .../csharp_dotnetcore/11.qnamaker/Startup.cs | 23 +++++------ .../13.core-bot.tests/CoreBot.Tests.csproj | 8 ++-- .../13.core-bot/Bots/DialogBot.cs | 2 +- .../13.core-bot/CoreBot.csproj | 10 ++--- .../csharp_dotnetcore/13.core-bot/Program.cs | 21 +++++----- .../csharp_dotnetcore/13.core-bot/Startup.cs | 25 ++++++------ .../14.nlp-with-dispatch/BotServices.cs | 2 - .../NLP-With-Dispatch-Bot.csproj | 10 ++--- .../14.nlp-with-dispatch/Program.cs | 21 +++++----- .../14.nlp-with-dispatch/Startup.cs | 24 ++++++------ .../HandlingAttachmentsBot.csproj | 6 +-- .../15.handling-attachments/Program.cs | 21 +++++----- .../15.handling-attachments/Startup.cs | 26 ++++++------- .../16.proactive-messages/ProactiveBot.csproj | 6 +-- .../16.proactive-messages/Program.cs | 21 +++++----- .../16.proactive-messages/Startup.cs | 22 ++++++----- .../AdapterWithErrorHandler.cs | 2 - .../MultiLingualBot.csproj | 6 +-- .../17.multilingual-bot/Program.cs | 25 ++++++------ .../17.multilingual-bot/Startup.cs | 25 ++++++------ .../AuthenticationBot.csproj | 8 ++-- .../18.bot-authentication/Bots/DialogBot.cs | 2 +- .../18.bot-authentication/Program.cs | 21 +++++----- .../18.bot-authentication/Startup.cs | 24 ++++++------ .../19.custom-dialogs/Bots/DialogBot.cs | 2 +- .../19.custom-dialogs/Custom-Dialogs.csproj | 8 ++-- .../19.custom-dialogs/Program.cs | 21 +++++----- .../19.custom-dialogs/Startup.cs | 24 ++++++------ .../21.corebot-app-insights/Bots/DialogBot.cs | 2 +- .../CoreBot-App-Insights.csproj | 14 +++---- .../21.corebot-app-insights/Program.cs | 21 +++++----- .../21.corebot-app-insights/Startup.cs | 25 ++++++------ .../Facebook-Events-Bot.csproj | 8 ++-- .../23.facebook-events/Program.cs | 25 ++++++------ .../23.facebook-events/Startup.cs | 24 ++++++------ .../BotAuthenticationMSGraph.csproj | 8 ++-- .../Bots/DialogBot.cs | 2 +- .../24.bot-authentication-msgraph/Program.cs | 21 +++++----- .../24.bot-authentication-msgraph/Startup.cs | 24 ++++++------ .../MessageReaction.csproj | 6 +-- .../25.message-reaction/Program.cs | 19 +++++++--- .../25.message-reaction/Startup.cs | 23 +++++------ .../Timex-Resolution.csproj | 5 ++- .../csharp_dotnetcore/42.scaleout/Program.cs | 21 +++++----- .../42.scaleout/ScaleoutBot.csproj | 8 ++-- .../csharp_dotnetcore/42.scaleout/Startup.cs | 22 ++++++----- .../43.complex-dialog/Bots/DialogBot.cs | 2 +- .../43.complex-dialog/ComplexDialogBot.csproj | 8 ++-- .../43.complex-dialog/Program.cs | 23 ++++++----- .../43.complex-dialog/Startup.cs | 24 ++++++------ .../ConversationFlow.cs | 7 +--- .../44.prompt-users-for-input/Program.cs | 21 +++++----- .../PromptUsersForInput.csproj | 6 +-- .../44.prompt-users-for-input/Startup.cs | 24 ++++++------ .../44.prompt-users-for-input/UserProfile.cs | 7 +--- .../Bots/StateManagementBot.cs | 2 +- .../45.state-management/Program.cs | 21 +++++----- .../45.state-management/Startup.cs | 25 ++++++------ .../StateMangementBot.csproj | 8 ++-- .../46.teams-auth/Bots/DialogBot.cs | 2 +- .../46.teams-auth/Program.cs | 21 +++++----- .../46.teams-auth/SimpleGraphClient.cs | 1 - .../46.teams-auth/Startup.cs | 22 ++++++----- .../46.teams-auth/TeamsAuth.csproj | 8 ++-- .../47.inspection/Inspection.csproj | 6 +-- .../47.inspection/Program.cs | 19 +++++++--- .../47.inspection/Startup.cs | 22 ++++++----- .../Bots/ActiveLearningBot.cs | 2 +- .../Program.cs | 21 ++++++---- .../QnAMakerActiveLearningBot.csproj | 10 ++--- .../Startup.cs | 22 ++++++----- .../Utils/CardHelper.cs | 5 +-- .../49.qnamaker-all-features/Bots/QnABot.cs | 3 +- .../Dialog/QnAMakerBaseDialog.cs | 4 -- .../Dialog/RootDialog.cs | 2 - .../49.qnamaker-all-features/Program.cs | 21 ++++++---- .../QnABotAllFeatures.csproj | 10 ++--- .../49.qnamaker-all-features/README.md | 2 +- .../49.qnamaker-all-features/Startup.cs | 22 ++++++----- .../Program.cs | 19 +++++++--- .../Startup.cs | 22 ++++++----- .../TeamsMessagingExtensionsSearch.csproj | 6 +-- .../Program.cs | 19 +++++++--- .../Startup.cs | 23 +++++------ .../TeamsMessagingExtensionsAction.csproj | 6 +-- .../Program.cs | 19 +++++++--- .../Startup.cs | 23 +++++------ ...MessagingExtensionsSearchAuthConfig.csproj | 6 +-- .../Program.cs | 19 +++++++--- .../Startup.cs | 23 +++++------ ...amsMessagingExtensionsActionPreview.csproj | 6 +-- .../AdapterWithErrorHandler.cs | 2 - .../Controllers/BotController.cs | 6 --- .../54.teams-task-module/Program.cs | 21 ++++++---- .../54.teams-task-module/Startup.cs | 23 +++++------ .../TeamsTaskModule.csproj | 6 +-- .../55.teams-link-unfurling/Program.cs | 22 ++++++++--- .../55.teams-link-unfurling/Startup.cs | 23 +++++------ .../TeamsLinkUnfurling.csproj | 6 +-- .../56.teams-file-upload/Program.cs | 30 +++++++-------- .../56.teams-file-upload/Startup.cs | 21 +++++----- .../TeamsFileUpload.csproj | 6 +-- .../57.teams-conversation-bot/Program.cs | 19 +++++++--- .../57.teams-conversation-bot/Startup.cs | 24 ++++++------ .../TeamsConversationBot.csproj | 6 +-- .../Bots/TeamsStartNewThreadInTeam.cs | 2 - .../Program.cs | 19 +++++++--- .../Startup.cs | 24 ++++++------ .../TeamsStartNewThreadInTeam.csproj | 6 +-- .../BotFrameworkAdapterWithErrorHandler.cs | 2 +- .../Adapters/SlackAdapterWithErrorHandler.cs | 2 +- .../60.slack-adapter/Bots/EchoBot.cs | 3 +- .../Controllers/BotController.cs | 2 +- .../Controllers/SlackController.cs | 2 +- .../60.slack-adapter/Program.cs | 21 +++++++--- .../60.slack-adapter/SlackAdapterBot.csproj | 7 ++-- .../60.slack-adapter/Startup.cs | 27 ++++++------- .../BotFrameworkAdapterWithErrorHandler.cs | 2 +- .../FacebookAdapterWithErrorHandler.cs | 2 +- .../61.facebook-adapter/Bots/EchoBot.cs | 2 +- .../Controllers/BotController.cs | 2 +- .../Controllers/FacebookController.cs | 2 +- .../FacebookAdapterBot.csproj | 7 ++-- .../61.facebook-adapter/Program.cs | 21 +++++++--- .../61.facebook-adapter/Startup.cs | 27 ++++++------- .../BotFrameworkAdapterWithErrorHandler.cs | 2 +- .../Adapters/WebexAdapterWithErrorHandler.cs | 2 +- .../62.webex-adapter/Bots/EchoBot.cs | 2 +- .../Controllers/BotController.cs | 2 +- .../Controllers/WebexController.cs | 2 +- .../62.webex-adapter/Program.cs | 21 +++++++--- .../62.webex-adapter/Startup.cs | 27 ++++++------- .../62.webex-adapter/WebexAdapterBot.csproj | 7 ++-- .../BotFrameworkAdapterWithErrorHandler.cs | 2 +- .../Adapters/TwilioAdapterWithErrorHandler.cs | 2 +- .../63.twilio-adapter/Bots/EchoBot.cs | 2 +- .../Controllers/BotController.cs | 2 +- .../Controllers/TwilioController.cs | 3 +- .../63.twilio-adapter/Program.cs | 21 +++++++--- .../63.twilio-adapter/Startup.cs | 27 ++++++------- .../63.twilio-adapter/TwilioAdapterBot.csproj | 7 ++-- .../Bots/QnAMultiturnBot.cs | 2 +- .../Dialog/RootDialog.cs | 1 - .../70.qnamaker-multiturn-sample/Program.cs | 19 +++++++--- .../QnAMultiturnBot.csproj | 10 ++--- .../70.qnamaker-multiturn-sample/Startup.cs | 22 ++++++----- .../EchoSkillBot/Bots/EchoBot.cs | 1 - .../EchoSkillBot/EchoSkillBot.csproj | 6 +-- .../EchoSkillBot/Program.cs | 22 ++++++++--- .../EchoSkillBot/Startup.cs | 23 ++++++----- .../SimpleRootBot/Program.cs | 22 ++++++++--- .../SimpleRootBot/SimpleRootBot.csproj | 6 +-- .../SimpleRootBot/Startup.cs | 23 ++++++----- .../echo-skill-bot/bot.js | 2 +- .../simple-root-bot/rootBot.js | 38 +++++++++---------- 180 files changed, 1297 insertions(+), 1074 deletions(-) diff --git a/samples/csharp_dotnetcore/01.console-echo/Console-EchoBot.csproj b/samples/csharp_dotnetcore/01.console-echo/Console-EchoBot.csproj index d2eda095f0..62f67b0199 100644 --- a/samples/csharp_dotnetcore/01.console-echo/Console-EchoBot.csproj +++ b/samples/csharp_dotnetcore/01.console-echo/Console-EchoBot.csproj @@ -4,12 +4,13 @@ Exe - netcoreapp2.1 + netcoreapp3.1 - - + + + diff --git a/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj b/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj index 5a1893eb6a..f7611a0be0 100644 --- a/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj +++ b/samples/csharp_dotnetcore/02.echo-bot/EchoBot.csproj @@ -1,13 +1,13 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/02.echo-bot/Program.cs b/samples/csharp_dotnetcore/02.echo-bot/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/02.echo-bot/Program.cs +++ b/samples/csharp_dotnetcore/02.echo-bot/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/02.echo-bot/Startup.cs b/samples/csharp_dotnetcore/02.echo-bot/Startup.cs index d3308ef336..c2d0ed4ae7 100644 --- a/samples/csharp_dotnetcore/02.echo-bot/Startup.cs +++ b/samples/csharp_dotnetcore/02.echo-bot/Startup.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -35,22 +35,24 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseWebSockets(); - //app.UseHttpsRedirection(); - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseWebSockets() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/03.welcome-user/Program.cs b/samples/csharp_dotnetcore/03.welcome-user/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/03.welcome-user/Program.cs +++ b/samples/csharp_dotnetcore/03.welcome-user/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/03.welcome-user/Startup.cs b/samples/csharp_dotnetcore/03.welcome-user/Startup.cs index d69620a9bb..50ee34d171 100644 --- a/samples/csharp_dotnetcore/03.welcome-user/Startup.cs +++ b/samples/csharp_dotnetcore/03.welcome-user/Startup.cs @@ -1,16 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Concurrent; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; -using Microsoft.Bot.Schema; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -19,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -35,22 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/03.welcome-user/WelcomeUser.csproj b/samples/csharp_dotnetcore/03.welcome-user/WelcomeUser.csproj index 3a334b6c25..5c5af02974 100644 --- a/samples/csharp_dotnetcore/03.welcome-user/WelcomeUser.csproj +++ b/samples/csharp_dotnetcore/03.welcome-user/WelcomeUser.csproj @@ -1,12 +1,12 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/05.multi-turn-prompt/Bots/DialogBot.cs b/samples/csharp_dotnetcore/05.multi-turn-prompt/Bots/DialogBot.cs index f13d6a5d0c..2b6ea3f177 100644 --- a/samples/csharp_dotnetcore/05.multi-turn-prompt/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/05.multi-turn-prompt/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/05.multi-turn-prompt/Dialogs/UserProfileDialog.cs b/samples/csharp_dotnetcore/05.multi-turn-prompt/Dialogs/UserProfileDialog.cs index f2f601f442..cc6137756a 100644 --- a/samples/csharp_dotnetcore/05.multi-turn-prompt/Dialogs/UserProfileDialog.cs +++ b/samples/csharp_dotnetcore/05.multi-turn-prompt/Dialogs/UserProfileDialog.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; -using System.Net.Mime; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; diff --git a/samples/csharp_dotnetcore/05.multi-turn-prompt/MultiTurnPromptBot.csproj b/samples/csharp_dotnetcore/05.multi-turn-prompt/MultiTurnPromptBot.csproj index 0de95e417e..b629fdcc07 100644 --- a/samples/csharp_dotnetcore/05.multi-turn-prompt/MultiTurnPromptBot.csproj +++ b/samples/csharp_dotnetcore/05.multi-turn-prompt/MultiTurnPromptBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/05.multi-turn-prompt/Program.cs b/samples/csharp_dotnetcore/05.multi-turn-prompt/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/05.multi-turn-prompt/Program.cs +++ b/samples/csharp_dotnetcore/05.multi-turn-prompt/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/05.multi-turn-prompt/Startup.cs b/samples/csharp_dotnetcore/05.multi-turn-prompt/Startup.cs index bb1bf134af..c73ebf94d8 100644 --- a/samples/csharp_dotnetcore/05.multi-turn-prompt/Startup.cs +++ b/samples/csharp_dotnetcore/05.multi-turn-prompt/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -39,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/06.using-cards/Bots/DialogBot.cs b/samples/csharp_dotnetcore/06.using-cards/Bots/DialogBot.cs index 5e3003ed9a..5136835d99 100644 --- a/samples/csharp_dotnetcore/06.using-cards/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/06.using-cards/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/06.using-cards/CardsBot.csproj b/samples/csharp_dotnetcore/06.using-cards/CardsBot.csproj index 0de95e417e..b629fdcc07 100644 --- a/samples/csharp_dotnetcore/06.using-cards/CardsBot.csproj +++ b/samples/csharp_dotnetcore/06.using-cards/CardsBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/06.using-cards/Program.cs b/samples/csharp_dotnetcore/06.using-cards/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/06.using-cards/Program.cs +++ b/samples/csharp_dotnetcore/06.using-cards/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/06.using-cards/Startup.cs b/samples/csharp_dotnetcore/06.using-cards/Startup.cs index 02dbfe57a3..7bcbf3a80c 100644 --- a/samples/csharp_dotnetcore/06.using-cards/Startup.cs +++ b/samples/csharp_dotnetcore/06.using-cards/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -39,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/07.using-adaptive-cards/AdaptiveCardsBot.csproj b/samples/csharp_dotnetcore/07.using-adaptive-cards/AdaptiveCardsBot.csproj index 9950f974f4..0fc4623b0e 100644 --- a/samples/csharp_dotnetcore/07.using-adaptive-cards/AdaptiveCardsBot.csproj +++ b/samples/csharp_dotnetcore/07.using-adaptive-cards/AdaptiveCardsBot.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/07.using-adaptive-cards/Program.cs b/samples/csharp_dotnetcore/07.using-adaptive-cards/Program.cs index 43e91da93e..c266d26a13 100644 --- a/samples/csharp_dotnetcore/07.using-adaptive-cards/Program.cs +++ b/samples/csharp_dotnetcore/07.using-adaptive-cards/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/07.using-adaptive-cards/Startup.cs b/samples/csharp_dotnetcore/07.using-adaptive-cards/Startup.cs index 2fa45befa4..c2d1f36acc 100644 --- a/samples/csharp_dotnetcore/07.using-adaptive-cards/Startup.cs +++ b/samples/csharp_dotnetcore/07.using-adaptive-cards/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -27,21 +25,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/08.suggested-actions/Bots/SuggestedActionsBot.cs b/samples/csharp_dotnetcore/08.suggested-actions/Bots/SuggestedActionsBot.cs index e699429dd7..be1b406a84 100644 --- a/samples/csharp_dotnetcore/08.suggested-actions/Bots/SuggestedActionsBot.cs +++ b/samples/csharp_dotnetcore/08.suggested-actions/Bots/SuggestedActionsBot.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; diff --git a/samples/csharp_dotnetcore/08.suggested-actions/Program.cs b/samples/csharp_dotnetcore/08.suggested-actions/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/08.suggested-actions/Program.cs +++ b/samples/csharp_dotnetcore/08.suggested-actions/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/08.suggested-actions/Startup.cs b/samples/csharp_dotnetcore/08.suggested-actions/Startup.cs index 81098a0405..439e4a1fe1 100644 --- a/samples/csharp_dotnetcore/08.suggested-actions/Startup.cs +++ b/samples/csharp_dotnetcore/08.suggested-actions/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -27,21 +25,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/08.suggested-actions/SuggestedActionsBot.csproj b/samples/csharp_dotnetcore/08.suggested-actions/SuggestedActionsBot.csproj index bd1ec5f636..d19a2d0941 100644 --- a/samples/csharp_dotnetcore/08.suggested-actions/SuggestedActionsBot.csproj +++ b/samples/csharp_dotnetcore/08.suggested-actions/SuggestedActionsBot.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/11.qnamaker/Program.cs b/samples/csharp_dotnetcore/11.qnamaker/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/11.qnamaker/Program.cs +++ b/samples/csharp_dotnetcore/11.qnamaker/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/11.qnamaker/QnABot.csproj b/samples/csharp_dotnetcore/11.qnamaker/QnABot.csproj index cbe55c8f7a..a6bff3918d 100644 --- a/samples/csharp_dotnetcore/11.qnamaker/QnABot.csproj +++ b/samples/csharp_dotnetcore/11.qnamaker/QnABot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/11.qnamaker/Startup.cs b/samples/csharp_dotnetcore/11.qnamaker/Startup.cs index b0cbf7b589..44f46838a3 100644 --- a/samples/csharp_dotnetcore/11.qnamaker/Startup.cs +++ b/samples/csharp_dotnetcore/11.qnamaker/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +17,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Add the HttpClientFactory to be used for the QnAMaker calls. services.AddHttpClient(); @@ -33,22 +33,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/13.core-bot.tests/CoreBot.Tests.csproj b/samples/csharp_dotnetcore/13.core-bot.tests/CoreBot.Tests.csproj index 1124fda276..1d03eb08c4 100644 --- a/samples/csharp_dotnetcore/13.core-bot.tests/CoreBot.Tests.csproj +++ b/samples/csharp_dotnetcore/13.core-bot.tests/CoreBot.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 false @@ -23,9 +23,9 @@ - - - + + + diff --git a/samples/csharp_dotnetcore/13.core-bot/Bots/DialogBot.cs b/samples/csharp_dotnetcore/13.core-bot/Bots/DialogBot.cs index b21a9eaaee..4d26cae35f 100644 --- a/samples/csharp_dotnetcore/13.core-bot/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/13.core-bot/Bots/DialogBot.cs @@ -35,7 +35,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/13.core-bot/CoreBot.csproj b/samples/csharp_dotnetcore/13.core-bot/CoreBot.csproj index f5d2f2ef32..9206b0ce09 100644 --- a/samples/csharp_dotnetcore/13.core-bot/CoreBot.csproj +++ b/samples/csharp_dotnetcore/13.core-bot/CoreBot.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 latest @@ -14,10 +14,10 @@ - - - - + + + + diff --git a/samples/csharp_dotnetcore/13.core-bot/Program.cs b/samples/csharp_dotnetcore/13.core-bot/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/13.core-bot/Program.cs +++ b/samples/csharp_dotnetcore/13.core-bot/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/13.core-bot/Startup.cs b/samples/csharp_dotnetcore/13.core-bot/Startup.cs index bfd8b0ff84..e1eae8ccc2 100644 --- a/samples/csharp_dotnetcore/13.core-bot/Startup.cs +++ b/samples/csharp_dotnetcore/13.core-bot/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.BotBuilderSamples.Dialogs; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +17,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -45,21 +45,24 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseWebSockets(); - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseWebSockets() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/14.nlp-with-dispatch/BotServices.cs b/samples/csharp_dotnetcore/14.nlp-with-dispatch/BotServices.cs index deff941508..fe59993dc4 100644 --- a/samples/csharp_dotnetcore/14.nlp-with-dispatch/BotServices.cs +++ b/samples/csharp_dotnetcore/14.nlp-with-dispatch/BotServices.cs @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using Microsoft.Bot.Builder.AI.Luis; using Microsoft.Bot.Builder.AI.QnA; -using Microsoft.Bot.Configuration; using Microsoft.Extensions.Configuration; namespace Microsoft.BotBuilderSamples diff --git a/samples/csharp_dotnetcore/14.nlp-with-dispatch/NLP-With-Dispatch-Bot.csproj b/samples/csharp_dotnetcore/14.nlp-with-dispatch/NLP-With-Dispatch-Bot.csproj index ed79da304a..75937828c2 100644 --- a/samples/csharp_dotnetcore/14.nlp-with-dispatch/NLP-With-Dispatch-Bot.csproj +++ b/samples/csharp_dotnetcore/14.nlp-with-dispatch/NLP-With-Dispatch-Bot.csproj @@ -1,15 +1,15 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - - - + + + + diff --git a/samples/csharp_dotnetcore/14.nlp-with-dispatch/Program.cs b/samples/csharp_dotnetcore/14.nlp-with-dispatch/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/14.nlp-with-dispatch/Program.cs +++ b/samples/csharp_dotnetcore/14.nlp-with-dispatch/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/14.nlp-with-dispatch/Startup.cs b/samples/csharp_dotnetcore/14.nlp-with-dispatch/Startup.cs index 524d93fd3c..d771093090 100644 --- a/samples/csharp_dotnetcore/14.nlp-with-dispatch/Startup.cs +++ b/samples/csharp_dotnetcore/14.nlp-with-dispatch/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -30,21 +28,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/15.handling-attachments/HandlingAttachmentsBot.csproj b/samples/csharp_dotnetcore/15.handling-attachments/HandlingAttachmentsBot.csproj index 9f93b00b89..fe2ac223a2 100644 --- a/samples/csharp_dotnetcore/15.handling-attachments/HandlingAttachmentsBot.csproj +++ b/samples/csharp_dotnetcore/15.handling-attachments/HandlingAttachmentsBot.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/15.handling-attachments/Program.cs b/samples/csharp_dotnetcore/15.handling-attachments/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/15.handling-attachments/Program.cs +++ b/samples/csharp_dotnetcore/15.handling-attachments/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/15.handling-attachments/Startup.cs b/samples/csharp_dotnetcore/15.handling-attachments/Startup.cs index 3274091467..20735a69c9 100644 --- a/samples/csharp_dotnetcore/15.handling-attachments/Startup.cs +++ b/samples/csharp_dotnetcore/15.handling-attachments/Startup.cs @@ -1,16 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Concurrent; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; -using Microsoft.Bot.Schema; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -19,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -29,21 +25,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/16.proactive-messages/ProactiveBot.csproj b/samples/csharp_dotnetcore/16.proactive-messages/ProactiveBot.csproj index bd1ec5f636..d19a2d0941 100644 --- a/samples/csharp_dotnetcore/16.proactive-messages/ProactiveBot.csproj +++ b/samples/csharp_dotnetcore/16.proactive-messages/ProactiveBot.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/16.proactive-messages/Program.cs b/samples/csharp_dotnetcore/16.proactive-messages/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/16.proactive-messages/Program.cs +++ b/samples/csharp_dotnetcore/16.proactive-messages/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/16.proactive-messages/Startup.cs b/samples/csharp_dotnetcore/16.proactive-messages/Startup.cs index 35f9cc6146..133486a70c 100644 --- a/samples/csharp_dotnetcore/16.proactive-messages/Startup.cs +++ b/samples/csharp_dotnetcore/16.proactive-messages/Startup.cs @@ -4,11 +4,11 @@ using System.Collections.Concurrent; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Schema; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +17,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -30,21 +30,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/17.multilingual-bot/AdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/17.multilingual-bot/AdapterWithErrorHandler.cs index 019eb806e0..8143fd0d0a 100644 --- a/samples/csharp_dotnetcore/17.multilingual-bot/AdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/17.multilingual-bot/AdapterWithErrorHandler.cs @@ -2,13 +2,11 @@ // Licensed under the MIT License. using System; -using System.Net.NetworkInformation; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Builder.TraceExtensions; -using Microsoft.Bot.Schema; using Microsoft.BotBuilderSamples.Translation; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; diff --git a/samples/csharp_dotnetcore/17.multilingual-bot/MultiLingualBot.csproj b/samples/csharp_dotnetcore/17.multilingual-bot/MultiLingualBot.csproj index 8e018ff2c7..9efecc2315 100644 --- a/samples/csharp_dotnetcore/17.multilingual-bot/MultiLingualBot.csproj +++ b/samples/csharp_dotnetcore/17.multilingual-bot/MultiLingualBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/17.multilingual-bot/Program.cs b/samples/csharp_dotnetcore/17.multilingual-bot/Program.cs index 2fa7387803..15de094baf 100644 --- a/samples/csharp_dotnetcore/17.multilingual-bot/Program.cs +++ b/samples/csharp_dotnetcore/17.multilingual-bot/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,20 +11,19 @@ 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) - .ConfigureLogging(logging => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - // Logging Options. - // Consider using Application Insights for your logging and metrics needs. - // https://azure.microsoft.com/en-us/services/application-insights/ - // .UseApplicationInsights() - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/17.multilingual-bot/Startup.cs b/samples/csharp_dotnetcore/17.multilingual-bot/Startup.cs index e71e20385b..113a2588c2 100644 --- a/samples/csharp_dotnetcore/17.multilingual-bot/Startup.cs +++ b/samples/csharp_dotnetcore/17.multilingual-bot/Startup.cs @@ -3,14 +3,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; - -using Microsoft.Bot.Builder.BotFramework; using Microsoft.BotBuilderSamples.Translation; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -26,7 +23,7 @@ public Startup() // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -48,21 +45,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/18.bot-authentication/AuthenticationBot.csproj b/samples/csharp_dotnetcore/18.bot-authentication/AuthenticationBot.csproj index 0de95e417e..b629fdcc07 100644 --- a/samples/csharp_dotnetcore/18.bot-authentication/AuthenticationBot.csproj +++ b/samples/csharp_dotnetcore/18.bot-authentication/AuthenticationBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/18.bot-authentication/Bots/DialogBot.cs b/samples/csharp_dotnetcore/18.bot-authentication/Bots/DialogBot.cs index 5e3003ed9a..5136835d99 100644 --- a/samples/csharp_dotnetcore/18.bot-authentication/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/18.bot-authentication/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/18.bot-authentication/Program.cs b/samples/csharp_dotnetcore/18.bot-authentication/Program.cs index 18d8b3fce9..15de094baf 100644 --- a/samples/csharp_dotnetcore/18.bot-authentication/Program.cs +++ b/samples/csharp_dotnetcore/18.bot-authentication/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging(logging => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/18.bot-authentication/Startup.cs b/samples/csharp_dotnetcore/18.bot-authentication/Startup.cs index 4569e82d83..afe77ef7d6 100644 --- a/samples/csharp_dotnetcore/18.bot-authentication/Startup.cs +++ b/samples/csharp_dotnetcore/18.bot-authentication/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -39,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/19.custom-dialogs/Bots/DialogBot.cs b/samples/csharp_dotnetcore/19.custom-dialogs/Bots/DialogBot.cs index 5e3003ed9a..5136835d99 100644 --- a/samples/csharp_dotnetcore/19.custom-dialogs/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/19.custom-dialogs/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/19.custom-dialogs/Custom-Dialogs.csproj b/samples/csharp_dotnetcore/19.custom-dialogs/Custom-Dialogs.csproj index 0de95e417e..b629fdcc07 100644 --- a/samples/csharp_dotnetcore/19.custom-dialogs/Custom-Dialogs.csproj +++ b/samples/csharp_dotnetcore/19.custom-dialogs/Custom-Dialogs.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/19.custom-dialogs/Program.cs b/samples/csharp_dotnetcore/19.custom-dialogs/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/19.custom-dialogs/Program.cs +++ b/samples/csharp_dotnetcore/19.custom-dialogs/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/19.custom-dialogs/Startup.cs b/samples/csharp_dotnetcore/19.custom-dialogs/Startup.cs index ac3178bf80..5ff51ac2b7 100644 --- a/samples/csharp_dotnetcore/19.custom-dialogs/Startup.cs +++ b/samples/csharp_dotnetcore/19.custom-dialogs/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -39,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/21.corebot-app-insights/Bots/DialogBot.cs b/samples/csharp_dotnetcore/21.corebot-app-insights/Bots/DialogBot.cs index 654e0af1d8..7e77b7b7dc 100644 --- a/samples/csharp_dotnetcore/21.corebot-app-insights/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/21.corebot-app-insights/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/21.corebot-app-insights/CoreBot-App-Insights.csproj b/samples/csharp_dotnetcore/21.corebot-app-insights/CoreBot-App-Insights.csproj index dd835aa8bc..997a5aeab6 100644 --- a/samples/csharp_dotnetcore/21.corebot-app-insights/CoreBot-App-Insights.csproj +++ b/samples/csharp_dotnetcore/21.corebot-app-insights/CoreBot-App-Insights.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + netcoreapp3.1 latest @@ -14,12 +14,12 @@ - - - - - - + + + + + + diff --git a/samples/csharp_dotnetcore/21.corebot-app-insights/Program.cs b/samples/csharp_dotnetcore/21.corebot-app-insights/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/21.corebot-app-insights/Program.cs +++ b/samples/csharp_dotnetcore/21.corebot-app-insights/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/21.corebot-app-insights/Startup.cs b/samples/csharp_dotnetcore/21.corebot-app-insights/Startup.cs index cf78b2f683..0bade090d1 100644 --- a/samples/csharp_dotnetcore/21.corebot-app-insights/Startup.cs +++ b/samples/csharp_dotnetcore/21.corebot-app-insights/Startup.cs @@ -4,7 +4,6 @@ using Microsoft.ApplicationInsights.Extensibility; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.ApplicationInsights; using Microsoft.Bot.Builder.Integration.ApplicationInsights.Core; @@ -12,6 +11,7 @@ using Microsoft.BotBuilderSamples.Bots; using Microsoft.BotBuilderSamples.Dialogs; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -20,7 +20,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -66,21 +66,24 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseWebSockets(); - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseWebSockets() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/23.facebook-events/Facebook-Events-Bot.csproj b/samples/csharp_dotnetcore/23.facebook-events/Facebook-Events-Bot.csproj index 01fecf6b6c..bd52022fc7 100644 --- a/samples/csharp_dotnetcore/23.facebook-events/Facebook-Events-Bot.csproj +++ b/samples/csharp_dotnetcore/23.facebook-events/Facebook-Events-Bot.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/23.facebook-events/Program.cs b/samples/csharp_dotnetcore/23.facebook-events/Program.cs index 2fa7387803..15de094baf 100644 --- a/samples/csharp_dotnetcore/23.facebook-events/Program.cs +++ b/samples/csharp_dotnetcore/23.facebook-events/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,20 +11,19 @@ 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) - .ConfigureLogging(logging => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - // Logging Options. - // Consider using Application Insights for your logging and metrics needs. - // https://azure.microsoft.com/en-us/services/application-insights/ - // .UseApplicationInsights() - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/23.facebook-events/Startup.cs b/samples/csharp_dotnetcore/23.facebook-events/Startup.cs index 6edab5dd08..e610ce01ca 100644 --- a/samples/csharp_dotnetcore/23.facebook-events/Startup.cs +++ b/samples/csharp_dotnetcore/23.facebook-events/Startup.cs @@ -3,14 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; -using Microsoft.Bot.Builder.BotFramework; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -23,7 +21,7 @@ public Startup() // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -33,21 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/BotAuthenticationMSGraph.csproj b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/BotAuthenticationMSGraph.csproj index 7ac7638408..2fa124d692 100644 --- a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/BotAuthenticationMSGraph.csproj +++ b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/BotAuthenticationMSGraph.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - + - - + + diff --git a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Bots/DialogBot.cs b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Bots/DialogBot.cs index d09535dd8b..9b8cc451ae 100644 --- a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Bots/DialogBot.cs @@ -35,7 +35,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Program.cs b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Program.cs +++ b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Startup.cs b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Startup.cs index 4569e82d83..afe77ef7d6 100644 --- a/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Startup.cs +++ b/samples/csharp_dotnetcore/24.bot-authentication-msgraph/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -39,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/25.message-reaction/MessageReaction.csproj b/samples/csharp_dotnetcore/25.message-reaction/MessageReaction.csproj index eec672ec0c..680eb36c9f 100644 --- a/samples/csharp_dotnetcore/25.message-reaction/MessageReaction.csproj +++ b/samples/csharp_dotnetcore/25.message-reaction/MessageReaction.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/25.message-reaction/Program.cs b/samples/csharp_dotnetcore/25.message-reaction/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/25.message-reaction/Program.cs +++ b/samples/csharp_dotnetcore/25.message-reaction/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/25.message-reaction/Startup.cs b/samples/csharp_dotnetcore/25.message-reaction/Startup.cs index a4c94c3d99..159f07e802 100644 --- a/samples/csharp_dotnetcore/25.message-reaction/Startup.cs +++ b/samples/csharp_dotnetcore/25.message-reaction/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -24,7 +24,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) services.AddSingleton(); @@ -42,22 +42,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/40.timex-resolution/Timex-Resolution.csproj b/samples/csharp_dotnetcore/40.timex-resolution/Timex-Resolution.csproj index 451541bf1f..5cdea3cece 100644 --- a/samples/csharp_dotnetcore/40.timex-resolution/Timex-Resolution.csproj +++ b/samples/csharp_dotnetcore/40.timex-resolution/Timex-Resolution.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp2.1 + netcoreapp3.1 @@ -14,7 +14,8 @@ - + + diff --git a/samples/csharp_dotnetcore/42.scaleout/Program.cs b/samples/csharp_dotnetcore/42.scaleout/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/42.scaleout/Program.cs +++ b/samples/csharp_dotnetcore/42.scaleout/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/42.scaleout/ScaleoutBot.csproj b/samples/csharp_dotnetcore/42.scaleout/ScaleoutBot.csproj index ad0649bc0a..bf55972b36 100644 --- a/samples/csharp_dotnetcore/42.scaleout/ScaleoutBot.csproj +++ b/samples/csharp_dotnetcore/42.scaleout/ScaleoutBot.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - + - - + + diff --git a/samples/csharp_dotnetcore/42.scaleout/Startup.cs b/samples/csharp_dotnetcore/42.scaleout/Startup.cs index 96e1783ec7..ba7cdd04e4 100644 --- a/samples/csharp_dotnetcore/42.scaleout/Startup.cs +++ b/samples/csharp_dotnetcore/42.scaleout/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +17,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the credential provider to be used with the Bot Framework Adapter. services.AddSingleton(); @@ -43,21 +43,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/43.complex-dialog/Bots/DialogBot.cs b/samples/csharp_dotnetcore/43.complex-dialog/Bots/DialogBot.cs index 5e3003ed9a..5136835d99 100644 --- a/samples/csharp_dotnetcore/43.complex-dialog/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/43.complex-dialog/Bots/DialogBot.cs @@ -34,7 +34,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/43.complex-dialog/ComplexDialogBot.csproj b/samples/csharp_dotnetcore/43.complex-dialog/ComplexDialogBot.csproj index 43e5834587..43a5962120 100644 --- a/samples/csharp_dotnetcore/43.complex-dialog/ComplexDialogBot.csproj +++ b/samples/csharp_dotnetcore/43.complex-dialog/ComplexDialogBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/43.complex-dialog/Program.cs b/samples/csharp_dotnetcore/43.complex-dialog/Program.cs index 594df6f5a2..15de094baf 100644 --- a/samples/csharp_dotnetcore/43.complex-dialog/Program.cs +++ b/samples/csharp_dotnetcore/43.complex-dialog/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } -} \ No newline at end of file +} diff --git a/samples/csharp_dotnetcore/43.complex-dialog/Startup.cs b/samples/csharp_dotnetcore/43.complex-dialog/Startup.cs index 23ab92b988..6c41ae165a 100644 --- a/samples/csharp_dotnetcore/43.complex-dialog/Startup.cs +++ b/samples/csharp_dotnetcore/43.complex-dialog/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; -using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -37,21 +35,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/44.prompt-users-for-input/ConversationFlow.cs b/samples/csharp_dotnetcore/44.prompt-users-for-input/ConversationFlow.cs index a5bbe6cb5b..dc7d5d2c33 100644 --- a/samples/csharp_dotnetcore/44.prompt-users-for-input/ConversationFlow.cs +++ b/samples/csharp_dotnetcore/44.prompt-users-for-input/ConversationFlow.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.BotBuilderSamples +namespace Microsoft.BotBuilderSamples { public class ConversationFlow { diff --git a/samples/csharp_dotnetcore/44.prompt-users-for-input/Program.cs b/samples/csharp_dotnetcore/44.prompt-users-for-input/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/44.prompt-users-for-input/Program.cs +++ b/samples/csharp_dotnetcore/44.prompt-users-for-input/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/44.prompt-users-for-input/PromptUsersForInput.csproj b/samples/csharp_dotnetcore/44.prompt-users-for-input/PromptUsersForInput.csproj index 9998021db2..b91331acdc 100644 --- a/samples/csharp_dotnetcore/44.prompt-users-for-input/PromptUsersForInput.csproj +++ b/samples/csharp_dotnetcore/44.prompt-users-for-input/PromptUsersForInput.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/44.prompt-users-for-input/Startup.cs b/samples/csharp_dotnetcore/44.prompt-users-for-input/Startup.cs index 10e83363aa..3ea3aa036a 100644 --- a/samples/csharp_dotnetcore/44.prompt-users-for-input/Startup.cs +++ b/samples/csharp_dotnetcore/44.prompt-users-for-input/Startup.cs @@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -17,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -36,21 +34,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/44.prompt-users-for-input/UserProfile.cs b/samples/csharp_dotnetcore/44.prompt-users-for-input/UserProfile.cs index 80559c6727..4927b3c672 100644 --- a/samples/csharp_dotnetcore/44.prompt-users-for-input/UserProfile.cs +++ b/samples/csharp_dotnetcore/44.prompt-users-for-input/UserProfile.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.BotBuilderSamples +namespace Microsoft.BotBuilderSamples { public class UserProfile { diff --git a/samples/csharp_dotnetcore/45.state-management/Bots/StateManagementBot.cs b/samples/csharp_dotnetcore/45.state-management/Bots/StateManagementBot.cs index 6ddcdf1bbb..becd2d1e7e 100644 --- a/samples/csharp_dotnetcore/45.state-management/Bots/StateManagementBot.cs +++ b/samples/csharp_dotnetcore/45.state-management/Bots/StateManagementBot.cs @@ -25,7 +25,7 @@ public StateManagementBot(ConversationState conversationState, UserState userSta { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await _conversationState.SaveChangesAsync(turnContext, false, cancellationToken); await _userState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/45.state-management/Program.cs b/samples/csharp_dotnetcore/45.state-management/Program.cs index 43e91da93e..15de094baf 100644 --- a/samples/csharp_dotnetcore/45.state-management/Program.cs +++ b/samples/csharp_dotnetcore/45.state-management/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/45.state-management/Startup.cs b/samples/csharp_dotnetcore/45.state-management/Startup.cs index 11186c2744..11e5e8ec07 100644 --- a/samples/csharp_dotnetcore/45.state-management/Startup.cs +++ b/samples/csharp_dotnetcore/45.state-management/Startup.cs @@ -3,13 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; -using Microsoft.Bot.Builder.Azure; -using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -18,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -61,21 +58,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/45.state-management/StateMangementBot.csproj b/samples/csharp_dotnetcore/45.state-management/StateMangementBot.csproj index dff1b46e25..1732a0ed0f 100644 --- a/samples/csharp_dotnetcore/45.state-management/StateMangementBot.csproj +++ b/samples/csharp_dotnetcore/45.state-management/StateMangementBot.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - + + + diff --git a/samples/csharp_dotnetcore/46.teams-auth/Bots/DialogBot.cs b/samples/csharp_dotnetcore/46.teams-auth/Bots/DialogBot.cs index d09535dd8b..9b8cc451ae 100644 --- a/samples/csharp_dotnetcore/46.teams-auth/Bots/DialogBot.cs +++ b/samples/csharp_dotnetcore/46.teams-auth/Bots/DialogBot.cs @@ -35,7 +35,7 @@ public DialogBot(ConversationState conversationState, UserState userState, T dia { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/46.teams-auth/Program.cs b/samples/csharp_dotnetcore/46.teams-auth/Program.cs index 18d8b3fce9..15de094baf 100644 --- a/samples/csharp_dotnetcore/46.teams-auth/Program.cs +++ b/samples/csharp_dotnetcore/46.teams-auth/Program.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -11,16 +11,19 @@ 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) - .ConfigureLogging(logging => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/46.teams-auth/SimpleGraphClient.cs b/samples/csharp_dotnetcore/46.teams-auth/SimpleGraphClient.cs index 1a0772b3c5..0ecce4adab 100644 --- a/samples/csharp_dotnetcore/46.teams-auth/SimpleGraphClient.cs +++ b/samples/csharp_dotnetcore/46.teams-auth/SimpleGraphClient.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; using Microsoft.Graph; diff --git a/samples/csharp_dotnetcore/46.teams-auth/Startup.cs b/samples/csharp_dotnetcore/46.teams-auth/Startup.cs index c11bf8d12c..d01f4e8c82 100644 --- a/samples/csharp_dotnetcore/46.teams-auth/Startup.cs +++ b/samples/csharp_dotnetcore/46.teams-auth/Startup.cs @@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -15,7 +15,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -37,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/46.teams-auth/TeamsAuth.csproj b/samples/csharp_dotnetcore/46.teams-auth/TeamsAuth.csproj index 9ae6ee560b..2782960f07 100644 --- a/samples/csharp_dotnetcore/46.teams-auth/TeamsAuth.csproj +++ b/samples/csharp_dotnetcore/46.teams-auth/TeamsAuth.csproj @@ -1,16 +1,16 @@  - netcoreapp2.1 + netcoreapp3.1 latest - + - - + + diff --git a/samples/csharp_dotnetcore/47.inspection/Inspection.csproj b/samples/csharp_dotnetcore/47.inspection/Inspection.csproj index 5a1893eb6a..f7611a0be0 100644 --- a/samples/csharp_dotnetcore/47.inspection/Inspection.csproj +++ b/samples/csharp_dotnetcore/47.inspection/Inspection.csproj @@ -1,13 +1,13 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/47.inspection/Program.cs b/samples/csharp_dotnetcore/47.inspection/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/47.inspection/Program.cs +++ b/samples/csharp_dotnetcore/47.inspection/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/47.inspection/Startup.cs b/samples/csharp_dotnetcore/47.inspection/Startup.cs index ce9b3ded88..6be64b27fc 100644 --- a/samples/csharp_dotnetcore/47.inspection/Startup.cs +++ b/samples/csharp_dotnetcore/47.inspection/Startup.cs @@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -16,7 +16,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); services.AddSingleton(); @@ -37,21 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Bots/ActiveLearningBot.cs b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Bots/ActiveLearningBot.cs index d2fa5fa9ad..33ab1e985f 100644 --- a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Bots/ActiveLearningBot.cs +++ b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Bots/ActiveLearningBot.cs @@ -88,7 +88,7 @@ public ActiveLearningBot(ConversationState conversationState, UserState userStat break; } - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Program.cs b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Program.cs index 45554c6f4c..15de094baf 100644 --- a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Program.cs +++ b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Program.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// -// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0 -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -12,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/QnAMakerActiveLearningBot.csproj b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/QnAMakerActiveLearningBot.csproj index 2f44fef8f4..ccaa3d841e 100644 --- a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/QnAMakerActiveLearningBot.csproj +++ b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/QnAMakerActiveLearningBot.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - - + + + + diff --git a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Startup.cs b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Startup.cs index 2d95ae5eeb..016b965012 100644 --- a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Startup.cs +++ b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Startup.cs @@ -5,11 +5,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -47,21 +47,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Utils/CardHelper.cs b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Utils/CardHelper.cs index 41908d41ae..ceab406776 100644 --- a/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Utils/CardHelper.cs +++ b/samples/csharp_dotnetcore/48.qnamaker-active-learning-bot/Utils/CardHelper.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; using Microsoft.Bot.Schema; namespace Microsoft.BotBuilderSamples diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/Bots/QnABot.cs b/samples/csharp_dotnetcore/49.qnamaker-all-features/Bots/QnABot.cs index aa12698d24..47b0a51f4d 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/Bots/QnABot.cs +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/Bots/QnABot.cs @@ -9,7 +9,6 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Schema; -using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples.Bots { @@ -30,7 +29,7 @@ public override async Task OnTurnAsync(ITurnContext turnContext, CancellationTok { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/QnAMakerBaseDialog.cs b/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/QnAMakerBaseDialog.cs index dd020fc6b9..dd41bfd19f 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/QnAMakerBaseDialog.cs +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/QnAMakerBaseDialog.cs @@ -1,10 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.AI.QnA; diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/RootDialog.cs b/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/RootDialog.cs index ed43e5161d..571948d15b 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/RootDialog.cs +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/Dialog/RootDialog.cs @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Bot.Builder.AI.QnA; using Microsoft.Bot.Builder.AI.QnA.Dialogs; using Microsoft.Bot.Builder.Dialogs; diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/Program.cs b/samples/csharp_dotnetcore/49.qnamaker-all-features/Program.cs index 45554c6f4c..15de094baf 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/Program.cs +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/Program.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// -// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0 -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -12,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/QnABotAllFeatures.csproj b/samples/csharp_dotnetcore/49.qnamaker-all-features/QnABotAllFeatures.csproj index d2c2962dd3..3ed8a293ce 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/QnABotAllFeatures.csproj +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/QnABotAllFeatures.csproj @@ -1,16 +1,16 @@  - netcoreapp2.1 + netcoreapp3.1 latest 7e9cc97e-50d0-436e-8c72-a08b712b4ebf - - - - + + + + diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/README.md b/samples/csharp_dotnetcore/49.qnamaker-all-features/README.md index f3336c8145..e9278a7f11 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/README.md +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/README.md @@ -63,7 +63,7 @@ QnA Maker CLI to deploy the model. await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/49.qnamaker-all-features/Startup.cs b/samples/csharp_dotnetcore/49.qnamaker-all-features/Startup.cs index 4257361d3c..cb5514fe51 100644 --- a/samples/csharp_dotnetcore/49.qnamaker-all-features/Startup.cs +++ b/samples/csharp_dotnetcore/49.qnamaker-all-features/Startup.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.BotBuilderSamples.Dialog; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -50,21 +50,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Program.cs b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Program.cs +++ b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Startup.cs b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Startup.cs index cec6f40436..c5d2ade42f 100644 --- a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Startup.cs +++ b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/Startup.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -35,21 +35,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/TeamsMessagingExtensionsSearch.csproj b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/TeamsMessagingExtensionsSearch.csproj index 5a1893eb6a..f7611a0be0 100644 --- a/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/TeamsMessagingExtensionsSearch.csproj +++ b/samples/csharp_dotnetcore/50.teams-messaging-extensions-search/TeamsMessagingExtensionsSearch.csproj @@ -1,13 +1,13 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Program.cs b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Program.cs +++ b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Startup.cs b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Startup.cs index 3c040d8861..e23fe47a10 100644 --- a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Startup.cs +++ b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/Startup.cs @@ -3,14 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; -using System.Collections.Concurrent; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -26,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -36,21 +35,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/TeamsMessagingExtensionsAction.csproj b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/TeamsMessagingExtensionsAction.csproj index 5a1893eb6a..f7611a0be0 100644 --- a/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/TeamsMessagingExtensionsAction.csproj +++ b/samples/csharp_dotnetcore/51.teams-messaging-extensions-action/TeamsMessagingExtensionsAction.csproj @@ -1,13 +1,13 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Program.cs b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Program.cs +++ b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Startup.cs b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Startup.cs index c7d6ab57b1..abfa3fcc24 100644 --- a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Startup.cs +++ b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/Startup.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create storage and UserState for User configuration settings. services.AddSingleton(new MemoryStorage()); @@ -39,22 +39,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/TeamsMessagingExtensionsSearchAuthConfig.csproj b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/TeamsMessagingExtensionsSearchAuthConfig.csproj index 082f255f3c..bbbee78f9d 100644 --- a/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/TeamsMessagingExtensionsSearchAuthConfig.csproj +++ b/samples/csharp_dotnetcore/52.teams-messaging-extensions-search-auth-config/TeamsMessagingExtensionsSearchAuthConfig.csproj @@ -1,14 +1,14 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Program.cs b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Program.cs +++ b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Startup.cs b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Startup.cs index 9fae3e4ea8..aa740318f2 100644 --- a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Startup.cs +++ b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -24,7 +24,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) services.AddSingleton(); @@ -37,22 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/TeamsMessagingExtensionsActionPreview.csproj b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/TeamsMessagingExtensionsActionPreview.csproj index dfa380ad24..5cba092e18 100644 --- a/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/TeamsMessagingExtensionsActionPreview.csproj +++ b/samples/csharp_dotnetcore/53.teams-messaging-extensions-action-preview/TeamsMessagingExtensionsActionPreview.csproj @@ -1,14 +1,14 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/54.teams-task-module/AdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/54.teams-task-module/AdapterWithErrorHandler.cs index a1586ace58..ccc0838cbb 100644 --- a/samples/csharp_dotnetcore/54.teams-task-module/AdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/54.teams-task-module/AdapterWithErrorHandler.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; diff --git a/samples/csharp_dotnetcore/54.teams-task-module/Controllers/BotController.cs b/samples/csharp_dotnetcore/54.teams-task-module/Controllers/BotController.cs index 6db0f814f9..22306a10fc 100644 --- a/samples/csharp_dotnetcore/54.teams-task-module/Controllers/BotController.cs +++ b/samples/csharp_dotnetcore/54.teams-task-module/Controllers/BotController.cs @@ -3,16 +3,10 @@ // // Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0 -using System.Diagnostics; -using System.IO; -using System.Text; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -using Microsoft.Bot.Builder.Integration.AspNet.Core.Handlers; -using Newtonsoft.Json; namespace Microsoft.BotBuilderSamples.Controllers { diff --git a/samples/csharp_dotnetcore/54.teams-task-module/Program.cs b/samples/csharp_dotnetcore/54.teams-task-module/Program.cs index 45554c6f4c..15de094baf 100644 --- a/samples/csharp_dotnetcore/54.teams-task-module/Program.cs +++ b/samples/csharp_dotnetcore/54.teams-task-module/Program.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// -// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.5.0 -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -12,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/54.teams-task-module/Startup.cs b/samples/csharp_dotnetcore/54.teams-task-module/Startup.cs index 8e2d07d7f8..38f3069cea 100644 --- a/samples/csharp_dotnetcore/54.teams-task-module/Startup.cs +++ b/samples/csharp_dotnetcore/54.teams-task-module/Startup.cs @@ -5,12 +5,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -26,7 +26,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -36,22 +36,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/54.teams-task-module/TeamsTaskModule.csproj b/samples/csharp_dotnetcore/54.teams-task-module/TeamsTaskModule.csproj index dfa380ad24..5cba092e18 100644 --- a/samples/csharp_dotnetcore/54.teams-task-module/TeamsTaskModule.csproj +++ b/samples/csharp_dotnetcore/54.teams-task-module/TeamsTaskModule.csproj @@ -1,14 +1,14 @@ - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/55.teams-link-unfurling/Program.cs b/samples/csharp_dotnetcore/55.teams-link-unfurling/Program.cs index 9f98495981..15de094baf 100644 --- a/samples/csharp_dotnetcore/55.teams-link-unfurling/Program.cs +++ b/samples/csharp_dotnetcore/55.teams-link-unfurling/Program.cs @@ -1,17 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { public class Program { - public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/55.teams-link-unfurling/Startup.cs b/samples/csharp_dotnetcore/55.teams-link-unfurling/Startup.cs index 3b5cf47bd2..212453c951 100644 --- a/samples/csharp_dotnetcore/55.teams-link-unfurling/Startup.cs +++ b/samples/csharp_dotnetcore/55.teams-link-unfurling/Startup.cs @@ -3,12 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples.Bots; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -24,7 +24,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) services.AddSingleton(); @@ -37,22 +37,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - //app.UseHttpsRedirection(); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/55.teams-link-unfurling/TeamsLinkUnfurling.csproj b/samples/csharp_dotnetcore/55.teams-link-unfurling/TeamsLinkUnfurling.csproj index eb375f19bc..680eb36c9f 100644 --- a/samples/csharp_dotnetcore/55.teams-link-unfurling/TeamsLinkUnfurling.csproj +++ b/samples/csharp_dotnetcore/55.teams-link-unfurling/TeamsLinkUnfurling.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/56.teams-file-upload/Program.cs b/samples/csharp_dotnetcore/56.teams-file-upload/Program.cs index 4f3700fcb7..15de094baf 100644 --- a/samples/csharp_dotnetcore/56.teams-file-upload/Program.cs +++ b/samples/csharp_dotnetcore/56.teams-file-upload/Program.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples @@ -14,16 +11,19 @@ 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) - .ConfigureLogging((logging) => + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { - logging.AddDebug(); - logging.AddConsole(); - }) - .UseStartup(); + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/56.teams-file-upload/Startup.cs b/samples/csharp_dotnetcore/56.teams-file-upload/Startup.cs index a7aacfbeaf..a62ae034dd 100644 --- a/samples/csharp_dotnetcore/56.teams-file-upload/Startup.cs +++ b/samples/csharp_dotnetcore/56.teams-file-upload/Startup.cs @@ -3,13 +3,13 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -25,7 +25,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -38,22 +38,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // app.UseHttpsRedirection(); - app.UseMvc(); } } } diff --git a/samples/csharp_dotnetcore/56.teams-file-upload/TeamsFileUpload.csproj b/samples/csharp_dotnetcore/56.teams-file-upload/TeamsFileUpload.csproj index eb375f19bc..680eb36c9f 100644 --- a/samples/csharp_dotnetcore/56.teams-file-upload/TeamsFileUpload.csproj +++ b/samples/csharp_dotnetcore/56.teams-file-upload/TeamsFileUpload.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/57.teams-conversation-bot/Program.cs b/samples/csharp_dotnetcore/57.teams-conversation-bot/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/57.teams-conversation-bot/Program.cs +++ b/samples/csharp_dotnetcore/57.teams-conversation-bot/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/57.teams-conversation-bot/Startup.cs b/samples/csharp_dotnetcore/57.teams-conversation-bot/Startup.cs index 60d361ed3f..389674ac2d 100644 --- a/samples/csharp_dotnetcore/57.teams-conversation-bot/Startup.cs +++ b/samples/csharp_dotnetcore/57.teams-conversation-bot/Startup.cs @@ -3,14 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; -using System.Collections.Generic; -using System.Collections.Concurrent; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -26,7 +24,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -36,21 +34,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/57.teams-conversation-bot/TeamsConversationBot.csproj b/samples/csharp_dotnetcore/57.teams-conversation-bot/TeamsConversationBot.csproj index eb375f19bc..680eb36c9f 100644 --- a/samples/csharp_dotnetcore/57.teams-conversation-bot/TeamsConversationBot.csproj +++ b/samples/csharp_dotnetcore/57.teams-conversation-bot/TeamsConversationBot.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Bots/TeamsStartNewThreadInTeam.cs b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Bots/TeamsStartNewThreadInTeam.cs index dfc4109b5b..8c6b3dbfb6 100644 --- a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Bots/TeamsStartNewThreadInTeam.cs +++ b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Bots/TeamsStartNewThreadInTeam.cs @@ -1,14 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Teams; using Microsoft.Bot.Connector.Authentication; using Microsoft.Bot.Schema; -using Microsoft.Bot.Schema.Teams; using Microsoft.Extensions.Configuration; namespace Microsoft.BotBuilderSamples.Bots diff --git a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Program.cs b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Program.cs index 8a3b6c4a16..15de094baf 100644 --- a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Program.cs +++ b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.BotBuilderSamples { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Startup.cs b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Startup.cs index 94c9bc0e98..c1d5002b87 100644 --- a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Startup.cs +++ b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/Startup.cs @@ -3,14 +3,12 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.BotBuilderSamples.Bots; -using System.Collections.Generic; -using System.Collections.Concurrent; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { @@ -26,7 +24,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -36,21 +34,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/TeamsStartNewThreadInTeam.csproj b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/TeamsStartNewThreadInTeam.csproj index eb375f19bc..680eb36c9f 100644 --- a/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/TeamsStartNewThreadInTeam.csproj +++ b/samples/csharp_dotnetcore/58.teams-start-new-thread-in-channel/TeamsStartNewThreadInTeam.csproj @@ -1,13 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - + + diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/60.slack-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs index aff8ae7673..52c6d6ec27 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace SlackAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class BotFrameworkAdapterWithErrorHandler : BotFrameworkHttpAdapter { diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Adapters/SlackAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/60.slack-adapter/Adapters/SlackAdapterWithErrorHandler.cs index af79d314c5..bab6a9f10c 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Adapters/SlackAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Adapters/SlackAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace SlackAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class SlackAdapterWithErrorHandler : SlackAdapter { diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Bots/EchoBot.cs b/samples/csharp_dotnetcore/60.slack-adapter/Bots/EchoBot.cs index 588089e429..bd6ab95e07 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Bots/EchoBot.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Bots/EchoBot.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; @@ -13,7 +12,7 @@ using SlackAPI; using Attachment = Microsoft.Bot.Schema.Attachment; -namespace SlackAdapterBot.Bots +namespace Microsoft.BotBuilderSamples.Bots { /// /// An EchoBot class that extends from the ActivityHandler. diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Controllers/BotController.cs b/samples/csharp_dotnetcore/60.slack-adapter/Controllers/BotController.cs index 2cab138cb2..f8a32c927c 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Controllers/BotController.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Controllers/BotController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace SlackAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/messages")] [ApiController] diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Controllers/SlackController.cs b/samples/csharp_dotnetcore/60.slack-adapter/Controllers/SlackController.cs index aca7292ce1..53119490e5 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Controllers/SlackController.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Controllers/SlackController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder.Adapters.Slack; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace SlackAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/slack")] [ApiController] diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Program.cs b/samples/csharp_dotnetcore/60.slack-adapter/Program.cs index f66551571b..15de094baf 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Program.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Program.cs @@ -1,20 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace SlackAdapterBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/60.slack-adapter/SlackAdapterBot.csproj b/samples/csharp_dotnetcore/60.slack-adapter/SlackAdapterBot.csproj index cc55e437ab..61879d8647 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/SlackAdapterBot.csproj +++ b/samples/csharp_dotnetcore/60.slack-adapter/SlackAdapterBot.csproj @@ -1,12 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 + Microsoft.BotBuilderSamples - - + + diff --git a/samples/csharp_dotnetcore/60.slack-adapter/Startup.cs b/samples/csharp_dotnetcore/60.slack-adapter/Startup.cs index 74e9139544..4506483586 100644 --- a/samples/csharp_dotnetcore/60.slack-adapter/Startup.cs +++ b/samples/csharp_dotnetcore/60.slack-adapter/Startup.cs @@ -3,22 +3,22 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Slack; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; -using SlackAdapterBot.Adapters; -using SlackAdapterBot.Bots; +using Microsoft.Extensions.Hosting; +using Microsoft.BotBuilderSamples.Adapters; +using Microsoft.BotBuilderSamples.Bots; -namespace SlackAdapterBot +namespace Microsoft.BotBuilderSamples { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the default Bot Framework Adapter (used for Azure Bot Service channels and emulator). services.AddSingleton(); @@ -31,22 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // app.UseHttpsRedirection(); - app.UseMvc(); } } } diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs index da82cc84a2..52c6d6ec27 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace FacebookAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class BotFrameworkAdapterWithErrorHandler : BotFrameworkHttpAdapter { diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/FacebookAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/FacebookAdapterWithErrorHandler.cs index 71b5893462..bcc862bb8a 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/FacebookAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Adapters/FacebookAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace FacebookAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class FacebookAdapterWithErrorHandler : FacebookAdapter { diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Bots/EchoBot.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Bots/EchoBot.cs index 5f1be5691b..0cb90b1ef2 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Bots/EchoBot.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Bots/EchoBot.cs @@ -9,7 +9,7 @@ using Microsoft.Bot.Schema; using Newtonsoft.Json; -namespace FacebookAdapterBot.Bots +namespace Microsoft.BotBuilderSamples.Bots { public class EchoBot : ActivityHandler { diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/BotController.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/BotController.cs index 6ee345c134..a3044e426c 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/BotController.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/BotController.cs @@ -6,7 +6,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace FacebookAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/messages")] [ApiController] diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/FacebookController.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/FacebookController.cs index cd5da92e3c..e21b29e49c 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/FacebookController.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Controllers/FacebookController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder.Adapters.Facebook; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace FacebookAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/facebook")] [ApiController] diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/FacebookAdapterBot.csproj b/samples/csharp_dotnetcore/61.facebook-adapter/FacebookAdapterBot.csproj index 74b761e470..fc26f1ba04 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/FacebookAdapterBot.csproj +++ b/samples/csharp_dotnetcore/61.facebook-adapter/FacebookAdapterBot.csproj @@ -1,12 +1,13 @@  - netcoreapp2.1 + netcoreapp3.1 + Microsoft.BotBuilderSamples - - + + diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Program.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Program.cs index ba569d660f..15de094baf 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Program.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Program.cs @@ -1,20 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace FacebookAdapterBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/61.facebook-adapter/Startup.cs b/samples/csharp_dotnetcore/61.facebook-adapter/Startup.cs index 551eeacec9..92ed9c7256 100644 --- a/samples/csharp_dotnetcore/61.facebook-adapter/Startup.cs +++ b/samples/csharp_dotnetcore/61.facebook-adapter/Startup.cs @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using FacebookAdapterBot.Adapters; -using FacebookAdapterBot.Bots; +using Microsoft.BotBuilderSamples.Adapters; +using Microsoft.BotBuilderSamples.Bots; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Facebook; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; -namespace FacebookAdapterBot +namespace Microsoft.BotBuilderSamples { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the default Bot Framework Adapter (used for Azure Bot Service channels and emulator). services.AddSingleton(); @@ -31,22 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // app.UseHttpsRedirection(); - app.UseMvc(); } } } diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/62.webex-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs index 2669107dca..52c6d6ec27 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace WebexAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class BotFrameworkAdapterWithErrorHandler : BotFrameworkHttpAdapter { diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Adapters/WebexAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/62.webex-adapter/Adapters/WebexAdapterWithErrorHandler.cs index 3eabd03607..f3831c0d52 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Adapters/WebexAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Adapters/WebexAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace WebexAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class WebexAdapterWithErrorHandler : WebexAdapter { diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Bots/EchoBot.cs b/samples/csharp_dotnetcore/62.webex-adapter/Bots/EchoBot.cs index 70701cfa12..93574090b0 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Bots/EchoBot.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Bots/EchoBot.cs @@ -9,7 +9,7 @@ using Microsoft.Bot.Schema; using Newtonsoft.Json; -namespace WebexAdapterBot.Bots +namespace Microsoft.BotBuilderSamples.Bots { public class EchoBot : ActivityHandler { diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Controllers/BotController.cs b/samples/csharp_dotnetcore/62.webex-adapter/Controllers/BotController.cs index bd93647752..e319221df9 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Controllers/BotController.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Controllers/BotController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace WebexAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/messages")] [ApiController] diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Controllers/WebexController.cs b/samples/csharp_dotnetcore/62.webex-adapter/Controllers/WebexController.cs index d538f98ede..4fad599706 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Controllers/WebexController.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Controllers/WebexController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Webex; -namespace WebexAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/webex")] [ApiController] diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Program.cs b/samples/csharp_dotnetcore/62.webex-adapter/Program.cs index 9cfc58c054..15de094baf 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Program.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Program.cs @@ -1,20 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace WebexAdapterBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/62.webex-adapter/Startup.cs b/samples/csharp_dotnetcore/62.webex-adapter/Startup.cs index aa90572c3b..2589d1a854 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/Startup.cs +++ b/samples/csharp_dotnetcore/62.webex-adapter/Startup.cs @@ -3,22 +3,22 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Webex; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; -using WebexAdapterBot.Adapters; -using WebexAdapterBot.Bots; +using Microsoft.Extensions.Hosting; +using Microsoft.BotBuilderSamples.Adapters; +using Microsoft.BotBuilderSamples.Bots; -namespace WebexAdapterBot +namespace Microsoft.BotBuilderSamples { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the default Bot Framework Adapter. services.AddSingleton(); @@ -31,22 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // app.UseHttpsRedirection(); - app.UseMvc(); } } } diff --git a/samples/csharp_dotnetcore/62.webex-adapter/WebexAdapterBot.csproj b/samples/csharp_dotnetcore/62.webex-adapter/WebexAdapterBot.csproj index 973e97d0bd..9ac808e5e7 100644 --- a/samples/csharp_dotnetcore/62.webex-adapter/WebexAdapterBot.csproj +++ b/samples/csharp_dotnetcore/62.webex-adapter/WebexAdapterBot.csproj @@ -1,15 +1,16 @@  - netcoreapp2.1 + netcoreapp3.1 latest $(NoWarn),CS8002 + Microsoft.BotBuilderSamples - - + + diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs index 82c9a7a60e..774c4fbca1 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/BotFrameworkAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace TwilioAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class BotFrameworkAdapterWithErrorHandler : BotFrameworkHttpAdapter { diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/TwilioAdapterWithErrorHandler.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/TwilioAdapterWithErrorHandler.cs index f9c6ab6b38..5b80de9e3d 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/TwilioAdapterWithErrorHandler.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Adapters/TwilioAdapterWithErrorHandler.cs @@ -6,7 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -namespace TwilioAdapterBot.Adapters +namespace Microsoft.BotBuilderSamples.Adapters { public class TwilioAdapterWithErrorHandler : TwilioAdapter { diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Bots/EchoBot.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Bots/EchoBot.cs index d17a7923a7..5e6debc561 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Bots/EchoBot.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Bots/EchoBot.cs @@ -6,7 +6,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Schema; -namespace TwilioAdapterBot.Bots +namespace Microsoft.BotBuilderSamples.Bots { public class EchoBot : ActivityHandler { diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/BotController.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/BotController.cs index 05961e0865..f8a32c927c 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/BotController.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/BotController.cs @@ -7,7 +7,7 @@ using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace TwilioAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/messages")] [ApiController] diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/TwilioController.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/TwilioController.cs index 9eacf948c9..6117709da1 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/TwilioController.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Controllers/TwilioController.cs @@ -6,9 +6,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Twilio; -using Microsoft.Bot.Builder.Integration.AspNet.Core; -namespace TwilioAdapterBot.Controllers +namespace Microsoft.BotBuilderSamples.Controllers { [Route("api/twilio")] [ApiController] diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Program.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Program.cs index 98af68a7d3..15de094baf 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Program.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Program.cs @@ -1,20 +1,29 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace TwilioAdapterBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/Startup.cs b/samples/csharp_dotnetcore/63.twilio-adapter/Startup.cs index a984793a74..583bfa6759 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/Startup.cs +++ b/samples/csharp_dotnetcore/63.twilio-adapter/Startup.cs @@ -3,22 +3,22 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Adapters.Twilio; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Extensions.DependencyInjection; -using TwilioAdapterBot.Adapters; -using TwilioAdapterBot.Bots; +using Microsoft.Extensions.Hosting; +using Microsoft.BotBuilderSamples.Adapters; +using Microsoft.BotBuilderSamples.Bots; -namespace TwilioAdapterBot +namespace Microsoft.BotBuilderSamples { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the default Bot Framework Adapter (used for Azure Bot Service channels and emulator). services.AddSingleton(); @@ -31,22 +31,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); // app.UseHttpsRedirection(); - app.UseMvc(); } } } diff --git a/samples/csharp_dotnetcore/63.twilio-adapter/TwilioAdapterBot.csproj b/samples/csharp_dotnetcore/63.twilio-adapter/TwilioAdapterBot.csproj index 7abe6df265..f2bdfa4ba4 100644 --- a/samples/csharp_dotnetcore/63.twilio-adapter/TwilioAdapterBot.csproj +++ b/samples/csharp_dotnetcore/63.twilio-adapter/TwilioAdapterBot.csproj @@ -1,13 +1,14 @@  - netcoreapp2.1 + netcoreapp3.1 latest + Microsoft.BotBuilderSamples - - + + diff --git a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Bots/QnAMultiturnBot.cs b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Bots/QnAMultiturnBot.cs index e73cb42bcf..abcd1f5265 100644 --- a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Bots/QnAMultiturnBot.cs +++ b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Bots/QnAMultiturnBot.cs @@ -27,7 +27,7 @@ public override async Task OnTurnAsync(ITurnContext turnContext, CancellationTok { await base.OnTurnAsync(turnContext, cancellationToken); - // Save any state changes that might have occured during the turn. + // Save any state changes that might have occurred during the turn. await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken); await UserState.SaveChangesAsync(turnContext, false, cancellationToken); } diff --git a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Dialog/RootDialog.cs b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Dialog/RootDialog.cs index af51f84de1..c4610c2155 100644 --- a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Dialog/RootDialog.cs +++ b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Dialog/RootDialog.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder.AI.QnA; -using Microsoft.Bot.Builder.AI.QnA.Dialogs; using Microsoft.Bot.Builder.Dialogs; using Microsoft.Bot.Schema; diff --git a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Program.cs b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Program.cs index 3d894617e0..9ced77500a 100644 --- a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Program.cs +++ b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Program.cs @@ -1,8 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; namespace QnAMultiturnBot { @@ -10,11 +11,19 @@ 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/QnAMultiturnBot.csproj b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/QnAMultiturnBot.csproj index 5b255c4322..3e60c3c863 100644 --- a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/QnAMultiturnBot.csproj +++ b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/QnAMultiturnBot.csproj @@ -1,15 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 latest - - - - + + + + diff --git a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Startup.cs b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Startup.cs index 7ef063a4b5..744947a365 100644 --- a/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Startup.cs +++ b/samples/csharp_dotnetcore/70.qnamaker-multiturn-sample/Startup.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.BotBuilderSamples; @@ -11,6 +10,7 @@ using Microsoft.BotBuilderSamples.Dialog; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace QnAMultiturnBot { @@ -26,7 +26,7 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton(); @@ -51,21 +51,23 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - app.UseDefaultFiles(); - app.UseStaticFiles(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); - app.UseMvc(); + // app.UseHttpsRedirection(); } } } diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Bots/EchoBot.cs b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Bots/EchoBot.cs index b6441e2905..2559115ec6 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Bots/EchoBot.cs +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Bots/EchoBot.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Bot.Builder; diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/EchoSkillBot.csproj b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/EchoSkillBot.csproj index 6486c79baf..9ccc4aaa81 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/EchoSkillBot.csproj +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/EchoSkillBot.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 latest f94e58a2-e019-4a0c-a6c2-59ecb1115b80 Microsoft.BotBuilderSamples.EchoSkillBot @@ -13,8 +13,8 @@ - - + + diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Program.cs b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Program.cs index 5fea40a049..b93b8d282f 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Program.cs +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Program.cs @@ -1,20 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.BotBuilderSamples.EchoSkillBot; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace Microsoft.BotBuilderSamples.EchoSkillBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Startup.cs b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Startup.cs index 1f67161980..aa76a57c2b 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Startup.cs +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/EchoSkillBot/Startup.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; @@ -12,6 +11,7 @@ using Microsoft.BotBuilderSamples.EchoSkillBot.Bots; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples.EchoSkillBot { @@ -20,7 +20,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Configure credentials services.AddSingleton(); @@ -36,22 +36,21 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - - app.UseDefaultFiles(); - app.UseStaticFiles(); - // app.UseHttpsRedirection(); - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Program.cs b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Program.cs index 5f0f923f9c..138557d235 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Program.cs +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Program.cs @@ -1,20 +1,30 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.BotBuilderSamples.SimpleRootBot; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; -namespace Microsoft.BotBuilderSamples.SimpleRootBot +namespace Microsoft.BotBuilderSamples { 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(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.ConfigureLogging((logging) => + { + logging.AddDebug(); + logging.AddConsole(); + }); + webBuilder.UseStartup(); + }); } } diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/SimpleRootBot.csproj b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/SimpleRootBot.csproj index 52b5249df4..4599ed5a7d 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/SimpleRootBot.csproj +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/SimpleRootBot.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + netcoreapp3.1 latest 6310bd04-2272-4a74-82fa-6791f5c7e115 Microsoft.BotBuilderSamples.SimpleRootBot @@ -13,8 +13,8 @@ - - + + diff --git a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Startup.cs b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Startup.cs index 0ba4eb19ea..4392c590e3 100644 --- a/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Startup.cs +++ b/samples/csharp_dotnetcore/80.skills-simple-bot-to-bot/SimpleRootBot/Startup.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.BotFramework; using Microsoft.Bot.Builder.Integration.AspNet.Core; @@ -13,6 +12,7 @@ using Microsoft.BotBuilderSamples.SimpleRootBot.Authentication; using Microsoft.BotBuilderSamples.SimpleRootBot.Bots; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples.SimpleRootBot { @@ -21,7 +21,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers().AddNewtonsoftJson(); // Configure credentials services.AddSingleton(); @@ -53,22 +53,21 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } - else - { - app.UseHsts(); - } - - app.UseDefaultFiles(); - app.UseStaticFiles(); - // app.UseHttpsRedirection(); - app.UseMvc(); + app.UseDefaultFiles() + .UseStaticFiles() + .UseRouting() + .UseAuthorization() + .UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); } } } diff --git a/samples/javascript_nodejs/80.skills-simple-bot-to-bot/echo-skill-bot/bot.js b/samples/javascript_nodejs/80.skills-simple-bot-to-bot/echo-skill-bot/bot.js index 1d3f2577ed..d379a4378d 100644 --- a/samples/javascript_nodejs/80.skills-simple-bot-to-bot/echo-skill-bot/bot.js +++ b/samples/javascript_nodejs/80.skills-simple-bot-to-bot/echo-skill-bot/bot.js @@ -25,7 +25,7 @@ class EchoBot extends ActivityHandler { await next(); }); - this.onUnrecognizedActivityType(async (context, next) => { + this.onEndOfConversation(async (context, next) => { // This will be called if the root bot is ending the conversation. Sending additional messages should be // avoided as the conversation may have been deleted. // Perform cleanup of resources if needed. diff --git a/samples/javascript_nodejs/80.skills-simple-bot-to-bot/simple-root-bot/rootBot.js b/samples/javascript_nodejs/80.skills-simple-bot-to-bot/simple-root-bot/rootBot.js index 751c1d0db8..74ee1a9d89 100644 --- a/samples/javascript_nodejs/80.skills-simple-bot-to-bot/simple-root-bot/rootBot.js +++ b/samples/javascript_nodejs/80.skills-simple-bot-to-bot/simple-root-bot/rootBot.js @@ -64,30 +64,28 @@ class RootBot extends ActivityHandler { await next(); }); - this.onUnrecognizedActivityType(async (context, next) => { - // Handle EndOfConversation returned by the skill. - if (context.activity.type === ActivityTypes.EndOfConversation) { - // Stop forwarding activities to Skill. - await this.activeSkillProperty.set(context, undefined); - - // Show status message, text and value returned by the skill - let eocActivityMessage = `Received ${ ActivityTypes.EndOfConversation }.\n\nCode: ${ context.activity.code }`; - if (context.activity.text) { - eocActivityMessage += `\n\nText: ${ context.activity.text }`; - } + // Handle EndOfConversation returned by the skill. + this.onEndOfConversation(async (context, next) => { + // Stop forwarding activities to Skill. + await this.activeSkillProperty.set(context, undefined); + + // Show status message, text and value returned by the skill + let eocActivityMessage = `Received ${ ActivityTypes.EndOfConversation }.\n\nCode: ${ context.activity.code }`; + if (context.activity.text) { + eocActivityMessage += `\n\nText: ${ context.activity.text }`; + } - if (context.activity.value) { - eocActivityMessage += `\n\nValue: ${ context.activity.value }`; - } + if (context.activity.value) { + eocActivityMessage += `\n\nValue: ${ context.activity.value }`; + } - await context.sendActivity(eocActivityMessage); + await context.sendActivity(eocActivityMessage); - // We are back at the root - await context.sendActivity('Back in the root bot. Say \'skill\' and I\'ll patch you through'); + // We are back at the root + await context.sendActivity('Back in the root bot. Say \'skill\' and I\'ll patch you through'); - // Save conversation state - await this.conversationState.saveChanges(context, true); - } + // Save conversation state + await this.conversationState.saveChanges(context, true); // By calling next() you ensure that the next BotHandler is run. await next();