IntelliSense in Visual Studio Code

Enabling IntelliSense

To enable IntelliSense support in Visual Studio Code follow these steps:

IntelliSense support for .cake files is provided through the C# extension for Visual Studio Code, along with Cake.Bakery.

  1. Open Visual Studio Code to the folder that you have a Cake file in.
  2. Install Cake extension for Visual Studio Code. Make sure at least version 0.10.1 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  3. Install C# extension for Visual Studio Code. Make sure at least version 1.13.0 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  4. Install Cake.Bakery using any of the following options:

    • Using Cake extension for Visual Studio Code:

      • Open command palette (Ctrl+Shift+P)
      • Type Cake
      • Select Install intellisense support command.
    • On Windows using Chocolatey:

      choco install cake-bakery.portable
    • Download Release ZIP, extract it and add it to PATH environment variable.

      If you want to install Cake.Bakery outside of the PATH environment variable you can specify the path to Cake.Bakery.exe using the OmniSharp Configuration System.

      Create a file called omnisharp.json in %USERPROFILE%/.omnisharp/ (~/.omnisharp/ if you are on Linux/macOS) with the following content (replace <custom_path> with the path to Cake.Bakery.):

      
      {
        "cake": {
          "bakeryPath": "<custom_path>/Cake.Bakery/tools/Cake.Bakery.exe"
        }
      }
      

IntelliSense support for Cake Frosting projects is provided through the C# extension for Visual Studio Code.

  1. Install C# extension for Visual Studio Code.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

IntelliSense support for .cake files is provided through the C# extension for Visual Studio Code, along with Cake.Bakery.

  1. Open Visual Studio Code to the folder that you have a Cake file in.
  2. Install Cake extension for Visual Studio Code. Make sure at least version 0.10.1 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  3. Install C# extension for Visual Studio Code. Make sure at least version 1.13.0 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  4. Make sure that Cake is installed in your tools folder. We recommend v0.22.0 or later, otherwise your addins will be installed twice. The easiest way to do this is to run your bootstrapping file (e.g. .\build.ps1).

    For Cake.Bakery Cake.Core.dll and Cake.exe need to be available in the same folder. Installation of Cake through Cake.Portable Chocolatey package therefore won't support IntelliSense.

  5. Install Cake.Bakery using any of the following options:

    • Using Cake extension for Visual Studio Code:

      • Open command palette (Ctrl+Shift+P)
      • Type Cake
      • Select Install intellisense support command.
    • On Windows using Chocolatey:

      choco install cake-bakery.portable
    • Download Release ZIP, extract it and add it to PATH environment variable.

      If you want to install Cake.Bakery outside of the PATH environment variable you can specify the path to Cake.Bakery.exe using the OmniSharp Configuration System.

      Create a file called omnisharp.json in %USERPROFILE%/.omnisharp/ (~/.omnisharp/ if you are on Linux/macOS) with the following content (replace <custom_path> with the path to Cake.Bakery.):

      
      {
        "cake": {
          "bakeryPath": "<custom_path>/Cake.Bakery/tools/Cake.Bakery.exe"
        }
      }
      
  6. Restart Visual Studio Code.

IntelliSense support for .cake files is provided through the C# extension for Visual Studio Code, along with Cake.Bakery.

  1. Open Visual Studio Code to the folder that you have a Cake file in.
  2. Install Cake extension for Visual Studio Code. Make sure at least version 0.10.1 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  3. Install C# extension for Visual Studio Code. Make sure at least version 1.13.0 is installed.

    For instructions how to install an extension in Visual Studio Code see Extension Marketplace documentation.

  4. Make sure that Cake.CoreCLR is installed in your tools folder. We recommend v0.22.0 or later, otherwise your addins will be installed twice. The easiest way to do this is to run your bootstrapping file (e.g. .\build.ps1).

    For Cake.Bakery Cake.Core.dll and Cake.dll need to be available in the same folder. Installation of Cake through Cake.Portable Chocolatey package therefore won't support IntelliSense.

  5. Install Cake.Bakery using any of the following options:

    • Using Cake extension for Visual Studio Code:

      • Open command palette (Ctrl+Shift+P)
      • Type Cake
      • Select Install intellisense support command.
    • On Windows using Chocolatey:

      choco install cake-bakery.portable
    • Download Release ZIP, extract it and add it to PATH environment variable.

      If you want to install Cake.Bakery outside of the PATH environment variable you can specify the path to Cake.Bakery.exe using the OmniSharp Configuration System.

      Create a file called omnisharp.json in %USERPROFILE%/.omnisharp/ (~/.omnisharp/ if you are on Linux/macOS) with the following content (replace <custom_path> with the path to Cake.Bakery.):

      
      {
        "cake": {
          "bakeryPath": "<custom_path>/Cake.Bakery/tools/Cake.Bakery.exe"
        }
      }
      
  6. Restart Visual Studio Code.

Troubleshooting

I've followed the steps, but I don't get any IntelliSense.

The C# extension for Visual Studio Code will automatically locate any *.sln file and use that as the target directory when starting OmniSharp. If your *.cake files are located in a different location, you might need to select Cake project in the project selector.

I've selected the Cake project, but still don't get IntelliSense.

Look in the OmniSharp Log for errors or warnings.

Here are some common errors and fixes:

[warn]: OmniSharp.Cake.CakeProjectSystem
    Cake script service not connected. Aborting.

This warning is an indication that Cake.Bakery isn't installed. See above how to install Cake.Bakery.

[fail]: OmniSharp.Cake.CakeProjectSystem
    c:\Users\mb\src\gh\bakery\setup.cake will be ignored due to an following error
    System.TypeLoadException: A null or zero length string does not represent a valid Type.

This error usually means that Cake isn't available. If using Cake Runner for .NET Framework make sure Cake is installed in your tools folder. The easiest way to do this is to run your bootstrapping file (e.g. .\build.ps1).

I don't see any error message and still don't get IntelliSense.

Look in the OmniSharp Log do you see anything even related to Cake if everything is setup correctly, you should at least see something similar to this:

[info]: OmniSharp.Cake.CakeProjectSystem
    Detecting Cake files in 'c:\Users\mb\src\gh\bakery'.
[info]: OmniSharp.Cake.CakeProjectSystem
    Found 29 Cake files.

If you don't, you probably have issues with getting the C# extension for Visual Studio Code installed. Please uninstall the extension and then try installing it again. Look for OmniSharp.Cake.dll in %userprofile%\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\ if you're on Windows and ~/.vscode/extensions/ms-vscode.csharp-1.13.0/.omnisharp/ if you are running Linux or Mac OS (replace 1.13.0 with the version of the C# extension for Visual Studio Code which you have installed).

How can I use a pre-release version of OmniSharp

To use a pre-release version of OmniSharp follow these steps:

  • Open command palette (Ctrl+Shift+P)

  • Select Open User Settings command

    Open user settings

  • Search for omnisharp.path and click Edit in settings.json

    omnisharp.path settings

  • Set "omnisharp.path": "latest" and save settings

  • Answer question if you want to restart OmniSharp server with yes

  • Wait until new version of OmniSharp is downloaded, installed and started

I tried everything above, I still don't get IntelliSense.

Submit an issue in the bakery repository on GitHub or reach out to us on Gitter.