Building AutoRest

Build Prerequisites

AutoRest is developed primarily in C# but generates code for multiple languages. To build and test AutoRest requires a few things be installed locally.

Setting up for development on AutoRest.

Expected time around 100 minutes to install.

Software Installed/operations:


See the actual script at:

   # download the install script and run it.
   iwr -OutFile c:\install-software.ps1 ; c:\install-software.ps1

After this script finishes, you’re done! No need to go through the instructions for manual setup.

Manual Setup


on Windows

Install the Microsoft Build Tools or get them with Visual Studio. Ensure that msbuild is in your path by running vcvarsall.bat

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat

To compile the code in Visual Studio IDE,

Install .Net CoreCLR RTM using these steps.

Mac/Linux instructions are out of date, and will be updated soon.

Testing Your Environment

To make sure you’ve set up all the prerequisites correctly, run .\Tools\Verify-Settings.ps1 before you attempt to build.


Visual Studio Build

AutoRest.sln is used to build AutoRest code generator.

Command Line

We use gulp and msbuild / xbuild to handle the builds. Install for global use with

npm install gulp -g


If you would like to see what commands are available to you, run gulp -T. That will list all of the gulp tasks you can run. By default, just running gulp will run a build that will execute clean, build, code analysis, package and test.

Output from gulp -T

[13:54:21] Using gulpfile ./autorest/gulpfile.js
[13:54:21] Tasks for ./autorest/gulpfile.js
[13:54:21] β”œβ”€β”€ regenerate:expected
[13:54:21] β”œβ”€β”€ regenerate:delete
[13:54:21] β”œβ”€β”€ regenerate:expected:csazure
[13:54:21] β”œβ”€β”€ regenerate:expected:cs
[13:54:21] β”œβ”€β”€ clean:build
[13:54:21] β”œβ”€β”€ clean:templates
[13:54:21] β”œβ”€β”€ clean:generatedTest
[13:54:21] β”œβ”€β”¬ clean
[13:54:21] β”‚ β”œβ”€β”€ clean:build
[13:54:21] β”‚ β”œβ”€β”€ clean:templates
[13:54:21] β”‚ └── clean:generatedTest
[13:54:21] β”œβ”€β”€ syncNugetProjs
[13:54:21] β”œβ”€β”€ syncNuspecs
[13:54:21] β”œβ”€β”¬ syncDotNetDependencies
[13:54:21] β”‚ β”œβ”€β”€ syncNugetProjs
[13:54:21] β”‚ └── syncNuspecs
[13:54:21] β”œβ”€β”€ build
[13:54:21] β”œβ”€β”€ package
[13:54:21] β”œβ”€β”€ test
[13:54:21] β”œβ”€β”€ analysis
[13:54:21] └── default

Running the tests

Prior to executing gulp to build and then test the code, make sure that the latest tools are setup for your build environment.

gulp test


Strong Name Validation Errors

If you’re running Windows and get errors like this while building:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly β€˜AutoRest, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A) β€”> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)

It means you need to disable strong name validation on your dev box:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe" -Vr * "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe" -Vr *

Running AutoRest

Command Line

After building, the AutoRest.exe executable will be output to the /binaries/net45/ folder. You can run it with the command line options specified in the Command Line Interface documentation.

Visual Studio

You can run (and debug) AutoRest by providing the command line parameters in the properties for the AutoRest project. To set these:

  1. Open the properties for the AutoRest project.
  2. Select the Debug tab.
  3. Set the Command line arguments field in the Start Options section.
  4. Build the entire solution to make sure the generators and modelers are built.
  5. F5 the project.


If the task runner window in Visual Studio does not show any tasks

Make sure that you have run npm install in the root folder.

If AutoRest.exe complains about not having generators for each language

Make sure that you have built the entire AutoRest.sln solution.

If you see the error gulp is not recognized as an internal or external command

gulp is located at C:\Users\[user]\AppData\Roaming\npm\gulp in Windows after you install it globally.

Releasing AutoRest