Skip to content

Commit 6e36327

Browse files
committed
RelayBot: Upgrade from .netcore2.1 to .net9.0
1 parent 5881d1a commit 6e36327

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

RelayBotSample/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
using Microsoft.AspNetCore;
54
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.Extensions.Hosting;
66

77
namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample
88
{
99
public class Program
1010
{
1111
public static void Main(string[] args)
1212
{
13-
CreateWebHostBuilder(args).Build().Run();
13+
CreateHostBuilder(args).Build().Run();
1414
}
1515

16-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
17-
WebHost.CreateDefaultBuilder(args)
18-
.UseStartup<Startup>();
16+
public static IHostBuilder CreateHostBuilder(string[] args) =>
17+
Host.CreateDefaultBuilder(args)
18+
.ConfigureWebHostDefaults(webBuilder =>
19+
{
20+
webBuilder.UseStartup<Startup>();
21+
});
1922
}
2023
}

RelayBotSample/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This bot has been created based on [Bot Framework](https://dev.botframework.com)
66

77
## Prerequisites
88

9-
- [.NET Core SDK](https://dotnet.microsoft.com/download) version 2.1
9+
- [.NET SDK](https://dotnet.microsoft.com/download) version 9.0
1010

1111
```bash
1212
# determine dotnet version

RelayBotSample/SampleBot.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.App" />
10-
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.5.1" />
9+
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.23.0" />
1110
<PackageReference Include="Microsoft.Bot.Connector.DirectLine" Version="3.0.2" />
1211
</ItemGroup>
1312

RelayBotSample/Startup.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
using Microsoft.AspNetCore.Builder;
55
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.AspNetCore.Mvc;
76
using Microsoft.Bot.Builder;
87
using Microsoft.Bot.Builder.Integration.AspNet.Core;
98
using Microsoft.Extensions.Configuration;
109
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Hosting;
1111
using Microsoft.PowerVirtualAgents.Samples.RelayBotSample.Bots;
1212

1313
namespace Microsoft.PowerVirtualAgents.Samples.RelayBotSample
@@ -24,7 +24,7 @@ public Startup(IConfiguration configuration)
2424
// This method gets called by the runtime. Use this method to add services to the container.
2525
public void ConfigureServices(IServiceCollection services)
2626
{
27-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
27+
services.AddControllers();
2828

2929
// Create the Bot Framework Adapter with error handling enabled.
3030
services.AddSingleton<IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();
@@ -44,7 +44,7 @@ public void ConfigureServices(IServiceCollection services)
4444
}
4545

4646
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
47-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
47+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4848
{
4949
if (env.IsDevelopment())
5050
{
@@ -55,10 +55,19 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
5555
app.UseHsts();
5656
}
5757

58+
// app.UseHttpsRedirection();
59+
5860
app.UseDefaultFiles();
5961
app.UseStaticFiles();
6062

61-
app.UseMvc();
63+
app.UseRouting();
64+
65+
app.UseAuthorization();
66+
67+
app.UseEndpoints(endpoints =>
68+
{
69+
endpoints.MapControllers();
70+
});
6271
}
6372
}
6473
}

0 commit comments

Comments
 (0)