Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Godot 3.2.3, Visual Studio 2019

This is a step by step guide to using this workaround for Godot 3.2.3+ support in Visual Studio: godotengine/godot-csharp-visualstudio#10 (comment)

  1. In the solution explorer, add a new project to your solution.

    image

  2. Search for library .net framework to find the "old-style" project style. Select it and press Next.

    image

  3. Set up the project.

    • Name: StubProj
    • Location: make sure this is your project directory.
    • Framework: the default is fine, we're going to replace this later anyway.

    image

  4. Open the StubProj directory. You can use Open Folder in File Explorer to do this easily.

    image

  5. Close Visual Studio. Press Yes if prompted to save files.

  6. In the StubFolder directory, delete all files and directories except StubProj.csproj. (Delete bin, obj, Properties, Class1.cs.)

  7. Open StubProj.csproj in a text editor. (Not Visual Studio.) Delete the content, then paste this text (a slightly modified version of the original workaround)

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProjectGuid>{B83A5A30-7D9A-4BCC-BB56-2974A2AAE767}</ProjectGuid>
        <OutputType>Library</OutputType>
        <RootNamespace>StubProj</RootNamespace>
        <AssemblyName>StubProj</AssemblyName>
        <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
        <FileAlignment>512</FileAlignment>
        <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
        <Deterministic>true</Deterministic>
        <ProjectTypeGuids>{8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <PlatformTarget>AnyCPU</PlatformTarget>
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <ProjectReference Include="..\*.csproj">
          <Private>False</Private>
        </ProjectReference>
      </ItemGroup>
      <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    </Project>
  8. Start Visual Studio. Open your Godot project back up.

  9. Set StubProj as your Startup Project.

    image

  10. See the extension's debugging options are there!

    image

@31
Copy link
Author

31 commented Oct 12, 2021

If you hit an error like this (image credit to @Atlinx, asking about this on the Godot Discord), it seems to mean the StubProj folder isn't inside the Godot project directory:

image

Make sure the StubProj folder is inside your Godot project folder.

@MikeWhitaker
Copy link

MikeWhitaker commented Nov 21, 2021

You need to add a reference to the game-project from the stub. Right click the references in the stub project and click add reference. Chose the game project. This resolves the issue.

@31
Copy link
Author

31 commented Nov 21, 2021

You kneed to add a reference to the game-project from the stub. Right click the references in the stub project and click add reference. Chose the game project. This resolves the issue.

The stub csproj file already includes the reference (this is what the ProjectReference means) so this shouldn't be necessary.

@MikeWhitaker
Copy link

MikeWhitaker commented Nov 22, 2021

Unless you make the folder outside of your godot project folder / directory. Then the reference is missing. ^^

@31
Copy link
Author

31 commented Nov 22, 2021

Yep, that's why the guide says to put it inside the project directory. 😄

@parachutingturtle
Copy link

parachutingturtle commented Feb 7, 2022

Hello. Any idea why this workaround would break IntelliSense code completion for me? Details here: godotengine/godot-csharp-visualstudio#26

@31
Copy link
Author

31 commented Feb 27, 2022

Hello. Any idea why this workaround would break IntelliSense code completion for me? Details here: godotengine/godot-csharp-visualstudio#26

I tried out these steps in VS 2022 and intellisense stopped working for me, too. Added a comment to godotengine/godot-csharp-visualstudio#26. I don't know how to fix it. 😢

@DasGandlaf
Copy link

DasGandlaf commented May 12, 2022

Debugging didnt use to work without this workaround. On the very newest version of Visual Studio (2022 - 17.2.0) it does seem to work for me. I didn't try it with other versions, but on this one, the workaround seems to work fine.

Edit: Autocompletion was working, until it decided not to, I don't know what it caused to stop. It was working while I was debugging, but now it stopped.

@Atlinx
Copy link

Atlinx commented May 25, 2022

I've tried Visual Studio 2022 v17.2.1 and everything works 😃

@BlizzCrafter
Copy link

BlizzCrafter commented May 26, 2022

I had a full working Visual Studio 2022 setup for 3 days, but unfortunately intellisense stopped working today :-/

v17.2.1 and v17.2.2

Everything else is still working.

Should I switch to Visual Studio 2019 / Visual Studio Code, or are their the same problems? Do you know if this will be fixed in Godot 3.5?

@31
Copy link
Author

31 commented May 26, 2022

Should I switch to Visual Studio 2019 / Visual Studio Code, or are their the same problems?

It seems that the workaround works better in VS 2019 than VS 2022. Visual Studio Code doesn't have these problems. (Neither does Rider.)

Do you know if this will be fixed in Godot 3.5?

I haven't seen any reason to think so.

@BlizzCrafter
Copy link

BlizzCrafter commented May 26, 2022

It seems that the workaround works better in VS 2019 than VS 2022. Visual Studio Code doesn't have these problems. (Neither does Rider.)

Indeed, VS 2019 works perfectly fine. I switched and have no errors or problems so far.

Thanks for all your answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment