Web Forms and SDK format of csproj

Viewed 260

Is there any way how to convert legacy Web Forms project to a new SDK csproj format? Tried everything. Web app can be build but cannot be run. It always ends with errors like "Program does not contain a static 'Main' method suitable for an entry point"

All I want is to switch nuget package references.

I just want to know if I'm doing something wrong or it is not possible.

EDIT: It is not just about nuget references, I simple want to simplify whole csproj and "include all". I want to get rid of csproj merge hell when adding content.

2 Answers

No.

Many of the benefits of the new SDK format come with the VS support of a new "project system" (what provides VS integration for the MSBuild C#/VB projects). They do not support classic ASP.NET applications (MVC, WebForms) or Web Site projects.

Yes it is possible.

You can use a third party SDK solution such as this:

Which enables you to migrate legacy AspNet projects that rely on System.Web assemblies to work using the new SDK-style csproj structure, including the use of PackageReference elements and any other modern features.

To use the SDK, just follow the documentation and add the reference to the SDK at the top of the csproj file like this (the version is mandatory):

<Project Sdk="MSBuild.SDK.SystemWeb/4.0.81">

This will then automatically download the SDK from nuget.org and work seamlessly.

Related