When you upgrade your bot from .net core 2.0/2.1 to 2.2 you may see an warning that states; ‘A PackageReference to ‘Microsoft.AspNetCore.All’ specified a Version of
2.2.1. Specifying the version of this package is not recommended’.
To avoid this warning;
- Right click the bot project in the solution explorer and ‘unload’ it.
- Right click the unloaded project and edit it
<PackageReference Include=”Microsoft.AspNetCore.All” Version=”2.2.1″/>
<PackageReference Include=”Microsoft.AspNetCore.All” />
- Reload the project.
.net core has moved away from web.config and app.config but realistically it’s a pattern that many projects will still want to follow. Fortunately there is help in the form of the System.Configuration.ConfigurationManager NuGet package. However, there is a snag when it comes to using this package with unit testing, it doesn’t work 😉 The problem is that it goes looking for a .config file related to the test host rather than your test project. I’m currently working around this with a quick static hack but the correct answer is to inject a new config. You can correct the path like this;
var myConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath;
myConfig = myConfig.Replace("testhost.dll.config", "MyProjectTests.dll");
var config = ConfigurationManager.OpenExeConfiguration(myConfig);
Hope that helps.
Just a quick one, when you are creating a brand new Bot Framework v4 project, the first thing you should do is go to the properties and change the Application->Target Framework to Asp.net core 2.1 and then go to Manage NuGet and update all the asp and bot libraries.