Installation - T4MVC/R4MVC GitHub Wiki
R4MVC Installation
R4MVC is distributed using using NuGet and consists of two main parts: the class library you reference in your ASP.NET Core project R4Mvc, and a code generator tool. There are two versions of the code gen tool: the dotnet cli tool R4Mvc.Tools.Cli, and a Visual Studio-loaded powershell wrapper R4Mvc.Tools.
CLI Tool
To use the cli tool, you'll have to install it either as a global tool, or pick a specific path to install it. There are benefits to either option.
If you're working on collaborative projects, and want all other developers to be able to run the tool, as well as ensure that they all run the same version, you can install the tool in a subpath of your repository, and commit it to your version control.
Local Install
To install the cli tool in a specific path, you'll have to run the following command:
dotnet tool install --tool-path 'path-in-your-repo' r4mvc.tools.cli --version {version-number}
If you're trying to install a prerelease version of the tool, you will also have to pass the --version {version-number}
attribute. Since R4Mvc is currently in alpha builds, you have to specify a version number every time you install or update it
Once installed, and having navigated to your asp.net project's directory, you can invoke it by calling:
./tool/path/r4mvc generate
Optionally, you can pass the project path parameter, instead of navigating there first:
./tool/path/r4mvc generate -p 'project path'
Global Install
To install the cli tool globally, run the following command:
dotnet tool install -g r4mvc.tools.cli
Once installed, you can run it in the same way from any directory, without pointing to a specific path for the tool:
r4mvc generate
Note
When you have installed both the local and the global tool on your machine, be aware which version you're running. When navigated to the path where the tool is installed, you may accidentally run the other version, instead of the one you intended.
If you want to make sure you run the local tool in the current path, you should specify the path in the command line. If you want to run the global tool, forgo the path:
# Local call
./r4mvc generate
# Global call
r4mvc generate
PowerShell wrapper
The Visual Studio powershell wrapper is installed as a NuGet reference in your project. Simply add this package to your ASP.NET Core project (or any project within your solution), and it will register the PowerShell module in your Visual Studio instance.
To call it, open the Package Manager Console (Tools Menu -> NuGet Package Manager -> Package Manager Console), select your ASP.NET Core project in the project dropdown, and run the following PowerShell command:
> Generate-R4MVC
Post install configuration
To be able to use the R4Mvc tag helpers in your application, you will need to register them in your views. Simply navigate to your Views/_ViewImports.cshtml
file, and add the following entry at the bottom of the file:
@addTagHelper *, R4Mvc
You will have to do this in the root Views
folder in your project, as well as doing the same change in the Views
folder of each mvc area.