New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft.VisualStudio.Web.CodeGeneration.Tools has been deprecated in favor of dotnet-aspnet-codegenerator #1075

AngelosP opened this Issue Jun 5, 2018 · 7 comments


None yet
7 participants

AngelosP commented Jun 5, 2018

Microsoft.VisualStudio.Web.CodeGeneration.Tools has been deprecated in favor of


This comment has been minimized.

rudiv commented Jun 5, 2018

I'm not clear what effect this has (as it hasn't been explained in these announcements), but I have to say that this package was the devil. Right Click -> Add -> Controller from an MVC Project, which drags this package in, is the worst thing that I keep forgetting I shouldn't do. By doing so, I'm immediately adding around 20 useless DLLs to my Publish.

With that I'm pretty confident that if this is what I think it is (something that won't drag in actual build dependencies / references to generate a ~15 line file), I'm massively excited about this change 🎉


This comment has been minimized.

MattJeanes commented Jun 5, 2018

Is this going to replace the automatic package addition in visual studio as described by @rudiv?


This comment has been minimized.

cilerler commented Jun 6, 2018

@AngelosP so is this mean we can run the line below on CommandPrompt

dotnet tool install --global dotnet-aspnet-codegenerator

and then remove the line below from project files?

<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />

This comment has been minimized.

vverrastro commented Jun 7, 2018

Hi all,
when I try to install dotnet-aspnet-codegenerator in my netcoreapp 2.1 from nuget manager, I have the following error:

Error Package 'dotnet-aspnet-codegenerator 2.1.0' has a package type 'DotnetTool' that is not supported by project 'myproject'.

Anyone have the same error?


This comment has been minimized.

seancpeters commented Jun 8, 2018

The dotnet aspnet-codegenerator global tool is only necessary to install when scaffolding from the command line. If you’re only scaffolding from Visual Studio, it is not necessary to install the global tool.

When scaffolding from Visual Studio, it’s no longer necessary to include the package reference to Microsoft.VisualStudio.Web.CodeGeneration.Tools. But scaffolding will still add the references needed by the generated content, as well as a reference to Microsoft.VisualStudio.Web.CodeGeneration.Design

If you want to scaffold from the command line, then the global tool should be installed from the command line, using the command:
dotnet tool install –global dotnet-aspnet-codegenerator

It should not be installed into any specific project via the nuget package manager in VS.


This comment has been minimized.

rudiv commented Jun 9, 2018

Ah, so this doesn't actually fix the deployment issue wherein lots of further (unneeded) files are dragged in to the project? That must be Microsoft.VisualStudio.Web.CodeGeneration.Design that I was referring to.

@natemcmaster natemcmaster changed the title from Microsoft.VisualStudio.Web.CodeGeneration.Tools has been deprecated in favor of to Microsoft.VisualStudio.Web.CodeGeneration.Tools has been deprecated in favor of dotnet-aspnet-codegenerator Oct 29, 2018


This comment has been minimized.

chrisckc commented Nov 27, 2018

dotnet-aspnet-codegenerator behaves differently from the previous tool, here is an example:

In the previous tool the following would create a valid configuration:
dotnet new mvc --auth Individual
then run the scaffolder tool to create the Identity UI

However using the new tool:
dotnet tool install --global dotnet-aspnet-codegenerator --version 2.1.6


dotnet new  mvc --auth Individual
dotnet-aspnet-codegenerator identity --force

All of the UI related setup is added under /Areas/Identity inside IdentityHostingStartup.cs and uses SqlServer rather then Sqlite, but Startup.cs is left untouched so the code generated by dotnet new mvc --auth Individual is left behind resulting in duplicated contexts and exception at runtime.

services.AddDbContext<ApplicationDbContext>(options =>

It seems that the new tool has been designed to add Identity to an existing non-identity enabled project, which seems to make sense, however the docs should cover this if not already.

EDIT: This is covered in the ScaffoldingReadme.txt

If your app was previously configured to use Identity, then you should remove the call to the AddIdentity method from your ConfigureServices method.

The only existing file touched by the new tool was appsettings.json to add a new connection string, which is why --force needed to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment