Search code examples
visual-studio-codecakebuild

VSCode Intellisense support for Cake


I followed the instructions on the website, but I don't get full cake support.

environment: linux, dotnet (6.0.302), vscode (1.70.0), c# extension (1.25.0), cake extension (2.0.0) - i.e. latest of everything

repro

  • dotnet new console --output /tmp/cake
  • code /tmp/cake
  • install c# extension, cake extension
  • reload
  • command: "Cake: install to workspace", accept all defaults
  • command: "Cake: update intellisense support"
  • reload
  • open build.cake

result:

  • no intellisense
  • red error squiggles under all cake functions, e.g. Setup, Teardown, Task, etc. - shows "The name 'Teardown' does not exist in the current context"
  • works: tasks in command palette
  • works: codelens items
  • works: snippets

logs:

  • no errors in Cake Workspace
  • no errors in OmniSharp Log and no messages related to cake, but it does show this when I open build.cake:
    [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
            No document found. File: /tmp/cake/build.cake.
    [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
            Could not find document for file /tmp/cake/build.cake
    

notes:

  • I ran dotnet tool install --global cake.tool
  • I also uninstalled and reinstalled all the extensions, without success
  • I didn't change any of the extension's options in .vscode/settings.json
  • I also tried this in an omnisharp.json file in the workspace root:
    {
      "cake": {
        "enabled": true,
        "bakeryPath": "~/.vscode/extensions/cake-build.cake-vscode-2.0.0/Cake.Bakery/tools/Cake.Bakery.exe"
      }
    }
    

Solution

  • Due to some constraints, OmniSharp (the basis for the VSCode C# extension, which also includes support for Cake) currently does not ship the support for Cake in the net6 versions.

    So you have two options here:

    • set "omnisharp.useModernNet": false in the vscode settings. This will not use the net6 version of OmniSharp and fall back the mono/.NET Framework versions.

    • set "omnisharp.path": "latest" in the vscode settings. This will always use the latest beta version of OmniSharp (at the time of writing, this is 1.39.2-beta.4). OmniSharp does (will?) ship support for Cake in the net6 versions starting with 1.39.1 (which is currently available for download, but not used in the c# extension for vs code.)