I find that The package:Microsoft.VisualStudio.CodeGeneration has over 20,000,000 downloads in the nuget.but I can not find any doc.
how to use it?
any articles about it?
I find that The package:Microsoft.VisualStudio.CodeGeneration has over 20,000,000 downloads in the nuget.but I can not find any doc.
how to use it?
any articles about it?
Basically, the package offers a single command to generate code:
dotnet aspnet-codegenerator {name}
You can find the source code here.
We don't use the Microsoft.VisualStudio.Web.CodeGeneration
directly unless we're creating a new command to generate code.
Because it is a command library for generic purpose, concrete commands are defined in other packages. For example, the dotnet aspnet-codegenerator controller
command is defined in Microsoft.VisualStudio.Web.CodeGenerators.Mvc. And the command dotnet aspnet-codegenerator identity
is also defined in the CG.MVC
package.
Usually , since this package is a generic purpose library, you won't reference this package directly. Instead, You'll add the package Microsoft.VisualStudio.Web.CodeGeneration.Design
. Be aware the Microsoft.VisualStudio.Web.CodeGeneration.Design
package has a dependency on Microsoft.VisualStudio.Web.CodeGenerators.Mvc
, and the Microsoft.VisualStudio.Web.CodeGenerators.Mvc
depends on Microsoft.VisualStudio.Web.CodeGeneration
:
Microsoft.VisualStudio.Web.CodeGeneration.Design | |(depends on) |-----------> Microsoft.VisualStudio.Web.CodeGenerators.Mvc | |(depends on) |-----------> Microsoft.VisualStudio.Web.CodeGeneration
Be aware the Microsoft.VisualStudio.Web.CodeGeneration.Design
is automatically added into your dependencies when you use Visual Studio to scaffold a controller/identity.
If you're using a VSCode/CLI, you need to manually add such a package reference. See https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-model?view=aspnetcore-3.0&tabs=visual-studio-code#add-nuget-packages
What @itminus says. I think the reason it has so many downloads is from the clear error message when you try to use dotnet aspnet-codegenerator
without Microsoft.VisualStudio.Web.CodeGeneration.Design
NuGet.
As of 2021-08-27 it has 90,672,569 total downloads
.
https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/
Example error:
Building project ...
Scaffolding failed.
Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference. To see more information, enable tracing by setting environment variable 'codegen_trace' = 1.
© 2022 - 2024 — McMap. All rights reserved.