I got a problem two days ago while working on a project.
When I try to create a new controller or a view by hovering over the View()
method and then clicking "Add View", VS generates nothing and no error message but these lines :
Finding the generator 'controller'...
Running the generator 'controller'...
Attempting to compile the application in memory.
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
I tried to update VS to latest version which is now 16.4.3 Community edition but with no luck.
Tried to reinstall Microsoft.VisualStudio.Web.CodeGeneration
from NuGet but no luck again.
Tried to delete .vs folder and no luck again.
What could be the problem? It was working normally before that but the scaffolding stopped working.
Thank you
It turns out it has something with a certain c# language syntax. Reading this issue on GitHub helped me to find a workaround.
What helped me fixing the problem is this comment:
By adding this package:
Microsoft.CodeAnalysis.CSharp.Workspaces
In the comment, the package version was 3.3.1, but I installed 3.4.0 and it works like a charm.