Microsoft.NET.Sdk.Functions 3.x includes references to Microsoft.AspNetCore.xxx in version 2.x
.
The actual Azure Functions runtime (also CLI for local development) provides the Microsoft.AspNetCore.xxx stack in version 3.x.
That means, if you use any AspNetCore class in an functions project (e.g. JsonResult from Mvc) you are developing against the 2.x version provided by the functions SDK. If you actually run the functions project (no matter if locally or in Azure) you are running the 3.x AspNetCore stack. That can cause quite a few issues, since there are breaking changes between AspNetCore 2.x und 3.x.
Example:
Usage of Microsoft.AspNetCore.Mvc.JsonResult with following constructor:
public JsonResult(object value, JsonSerializerSettings serializerSettings);
That does compile, but results in a runtime exception since there is no matching constructor.
I've tried to dirty-fix this by referencing the Web-SDK in the project file of the function project.
Before:
<Project Sdk="Microsoft.NET.Sdk">
After:
<Project Sdk="Microsoft.NET.Sdk.Web">
That actually makes Visual Studio aware of the AspNetCore framework 3.x. But I cannot compile nor run the project any longer since VS is complaining that:
CS5001: exe does not contain a static 'Main' method suitable for an entry point
With all due respect, but what is the whole idea of providing an SDK that diverges from the actual runtime?
Microsoft.NET.Sdk.Functions 3.x includes references to Microsoft.AspNetCore.xxx in version 2.x
The actual Azure Functions runtime (also CLI for local development) provides the Microsoft.AspNetCore.xxx stack in version 3.x. That means, if you use any AspNetCore class in an functions project (e.g. JsonResult from Mvc) you are developing against the 2.x version provided by the functions SDK. If you actually run the functions project (no matter if locally or in Azure) you are running the 3.x AspNetCore stack. That can cause quite a few issues, since there are breaking changes between AspNetCore 2.x und 3.x.
Example: Usage of Microsoft.AspNetCore.Mvc.JsonResult with following constructor:
public JsonResult(object value, JsonSerializerSettings serializerSettings);
That does compile, but results in a runtime exception since there is no matching constructor.
I've tried to dirty-fix this by referencing the Web-SDK in the project file of the function project. Before:
<Project Sdk="Microsoft.NET.Sdk">
After:
<Project Sdk="Microsoft.NET.Sdk.Web">
That actually makes Visual Studio aware of the AspNetCore framework 3.x. But I cannot compile nor run the project any longer since VS is complaining that:
CS5001: exe does not contain a static 'Main' method suitable for an entry point
With all due respect, but what is the whole idea of providing an SDK that diverges from the actual runtime?