Are they only needed at design time? Can they be removed without causing any build issues? (Targeting framework netcoreapp2.1).
AspNetCore. Razor. Design contains MSBuild support for Razor. If you're developing an asp.net core app, there's no need to add an package reference on Microsoft.
Razor Pages is a newer, simplified web application programming model. It removes much of the ceremony of ASP.NET MVC by adopting a file-based routing approach. Each Razor Pages file found under the Pages directory equates to an endpoint.
Razor is a markup syntax that lets you embed server-based code into web pages using C# and VB.Net. It is not a programming language. It is a server side markup language. Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML.
Razor markup is code that interacts with HTML markup to produce a webpage that's sent to the client. In ASP.NET Core MVC, views are .cshtml files that use the C# programming language in Razor markup. Usually, view files are grouped into folders named for each of the app's controllers.
The package of Microsoft.AspNetCore.Razor.Design
contains MSBuild support for Razor. If you're developing an asp.net core app, there's no need to add an package reference on Microsoft.AspNetCore.Razor.Design
manually (and also you're not supposed to remove them manually). Because it is referenced by Microsoft.AspNetCore.App
meta package, which means if you have a dependency on Microsoft.AspNetCore.App
, you'll reference the package automatically.
The package of Microsoft.VisualStudio.Web.CodeGeneration.Design
is a quite different one. As the name suggests, it is used to generate codes only. For example, you want to develop a project without Visual Studio
:
dotnet new mvc
App.Models.MyModel
mannuallyVisual Studio
to generate controllers, views, DbContext and so on. But what if we don't have Visual Studio
?If we have the Microsoft.VisualStudio.Web.CodeGeneration.Design
referenced in our *.csproj
file, we can create the CRUD scaffold using the following command :
dotnet aspnet-codegenerator controller -m $model -dc $dcClass -name $controllerName -namespace $controllerNamespace -outDir Controllers --useDefaultLayout
There're also some other sub commands such as :
dotnet aspnet-codegenerator identity -dc $dcClass
However, this package is only used to scaffold. Once you have the codes generated, you can feel free to remove this package before publish.
As a side note, to use the dotnet aspnet-codegenerator
command, we should first install the tool:
dotnet tool install --global dotnet-aspnet-codegenerator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With