PATH
environment variable (so the dotnet
command will work anywhere).Add this code into your .csproj
file in the root of your project, changing path\to\folder
to the folder with external code. Do not remove the \**
.
<ItemGroup>
<Compile Remove="path\to\folder\**" />
</ItemGroup>
The end result should look similar to this.
Please note that this uses Godot 4.1.3 and .NET 6.0, and is a new project.
<Project Sdk="Godot.NET.Sdk/4.1.3">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
<ItemGroup>
<Compile Remove="path\to\folder\**" />
</ItemGroup>
</Project>
In most cases, adding a project via dotnet new
will work fine.
Some cases, you might want references to the Godot API, in which case you need to create a new .csproj
manually like so.
Here is an example for .NET 6.0 and Godot 4.1.3
<Project Sdk="Godot.NET.Sdk/4.1.3">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>
.sln
Use dotnet add reference <path/to/.csproj>
in the root of your project to add a subproject to the main project.
Use dotnet sln add <path/to/.csproj>
in the root of your project to add a subproject to the .sln
.
.dll
references to the Main ProjectIf you have a .NET compatible .dll
in your project, you will need to edit the .csproj
manually.
Example code, where the .dll
is located in a folder called foo
and the file is named bar.dll
<Reference Include="bar">
<HintPath>foo\bar.dll</HintPath>
</Reference>
Hope this helps someone out there. If you have any questions feel free to ask on my Discord Server, X.com/Twitter, Mastodon.