CZEMacLeod / MSBuild.SDK.SystemWeb

This MSBuild SDK is designed to allow for the easy creation and use of SDK (shortform) projects targeting ASP.NET 4.x using System.Web.
MIT License
151 stars 8 forks source link

Cannot add Controller from Visual Studio context menu #23

Closed codestothestars closed 2 years ago

codestothestars commented 2 years ago

Attempting to do so shows an alert with the message "There are no scaffolders supported for this item."

Steps to reproduce:

  1. Right-click the Controllers folder
  2. Select Add -> Controller...

Workaround:

  1. Add -> New Item
  2. Create a plain C# class
  3. Change the class to a controller manually
CZEMacLeod commented 2 years ago

@codestothestars Unfortunately, a lot of the features of VS relating to MVC5 and WebApplicationProjects work based on the project type guids and only work in the older non-sdk project type. The new CPS project type uses ProjectCapabilitys to enable the visual studio extensions and menus. This means that a few things don't 'light up' when using the SDK project - this is one of them. The same is true in other areas, where the extension assumes it must be ASP.Net Core because it is CPS and tried to do things the new way. There may be a workaround for it, but I think it is likely we would need someone from the VS team to update the built-in functionality to detect CPS projects and possibly add new ProjectCapabilitys to resolve this (and a few of the other known limitations). I recommend using this only for legacy projects which mainly need faster build times and minor maintenance, rather than for any form of 'new' development work. In that case you would probably copy/paste an existing controller, or do as you did, and just add a class. If you are writing a new application, you would probably just use ASP.NET Core.

codestothestars commented 2 years ago

Understood, and I appreciate the feedback. I thought this might be out of scope, but wanted to put it out there just in case. Thank you for your work on this!

CZEMacLeod commented 2 years ago

@codestothestars No problem - a lot of this is just the cumulation of others work packaged together from the original github issue Add support for ASP.NET (non-Core) projects I would love to be able to enable this, and other, scenarios, and there may be more information elsewhere which would help with this, but I fear a lot of it would be down to the Microsoft and Visual Studio teams, who are pretty much only looking at .Net 6 / ASP.Net Core and the new x64 port and tooling. It would be nice if while they were in the code, they could sort some of this stuff for us to help those who have to maintain 'legacy' code bases.