I am creating an ASP.NET Core 6 application in which I want to integrate additional areas provided by separate assemblies. I follow the documentation at https://learn.microsoft.com/en-us/aspnet/core/mvc/advanced/app-parts?view=aspnetcore-6.0. In a project that provides app parts, I add an extension method for IMvcBuilder which allows me to register the parts assembly conveniently, for instance:
services.AddMvc().AddFeatureXyzParts();
The extension does nothing more like this:
public static IMvcBuilder AddFeatureXyzParts(this IMvcBuilder builder)
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
builder.AddApplicationPart(typeof(MvcBuilderExtensions).Assembly);
return builder;
}
In the project file, I changed the Sdk attribute from Microsoft.NET.Sdk to Microsoft.NET.Sdk.Web to reference the ASP.NET Core 6 SDK implicitly (as it is set up for the main application project), but this breaks the build with the error stating that the assembly lacks the definition of a Main method.
Since it is not a standalone web application assembly, but a parts library shipping additional controller types and services, I´d like to set the Sdk property back to Microsoft.NET.Sdk. Then I have to add missing package references manually. For this, the Microsoft.AspNetCore.App package seems to be the wrong choice for ASP.NET Core 6, and Microsoft.AspNetCore.App.Refs must not be used.
What references do I need instead?
Update - Define the required entry point to satisfy the build
As a workaround that allows me to reference the required ASP.NET Core 6 SDK, I can use the Microsoft.NET.Sdk.Web SDK if I add an internal Program class that defines a Main method. With this in place, I can register my part assembly as wanted, and controllers (even if part of an area) integrate nicely.
internal static class Program
{
public static void Main() => throw new NotImplementedException();
}
0 answers
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20416
7
13574
4






