DotVVM Command Line
When you create DotVVM project (ASP.NET Core) using DotVVM for Visual Studio or using dotnet new, the DotVVM Command Line tool should be already registered in the project file:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
...
<ItemGroup>
<DotNetCliToolReference Include="DotVVM.CommandLine" Version="2.0.0" />
</ItemGroup>
</Project>
This will allow to run commands starting with dotnet dotvvm ...
in the project directory to perform various actions with the DotVVM project.
Creating Pages, Master Pages and Markup Controls
DotVVM Command Line can create new pages, master pages and markup controls in ASP.NET Core projects.
Task | Short Syntax | Long Syntax | Options |
---|---|---|---|
Create Page | dotnet dotvvm ap |
dotnet dotvvm add page |
|
Create Master Page | dotnet dotvvm am |
dotnet dotvvm add master |
|
Create Markup Control | dotnet dotvvm ac |
dotnet dotvvm add control |
|
Examples
- Create the
Views/Site.dotmaster
master page:
dotnet dotvvm add master Site
- Create the
Views/Page1.dothtml
page and embed it in theViews/Site.dotmaster
:
dotnet dotvvm add page Page1 -m Site
- Create the
Controls/MyControl.dotcontrol
user control with the code behind file:
dotnet dotvvm add control Controls/MyControl.dotcontrol -c
Working with REST API Binding clients
This feature is new in DotVVM 2.0.
The DotVVM Command Line tool can also be used to add and update REST API Bindings clients.
Task | Syntax | Options |
---|---|---|
Add API Client | dotnet dotvvm api create |
|
Update API Client | dotnet dotvvm api regen |
|
The metadata of REST API Bindings are stored in dotvvm.json
file. If any of the parameters needs to be updated, change them in this file.
Please note that the API client needs to be registered in DotvvmStartup.cs
. See REST API Bindings chapter for more details.
Examples
- Registering the API client:
dotnet dotvvm api create http://localhost:43852/swagger/v1/swagger.json DotVVM2.Demo.RestApi.Api Api/ApiClient.cs wwwroot/Scripts/ApiClient.ts
- Updating the generated clients:
dotnet dotvvm api regen