Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Does Not Detect C# Extensions (or any .cs files that do not contain nodes) #14932

Closed
11clock opened this issue Dec 22, 2017 · 13 comments
Closed
Assignees
Milestone

Comments

@11clock
Copy link

11clock commented Dec 22, 2017

Godot version:
3.0 beta 2

OS/device including version:
Windows

Issue description:
When you make an extension method in another .cs class, build fails because it cannot find the extension you are attempting to reference.

Steps to reproduce:

  1. Create a .cs file with an extension to any node or whatever.
  2. In a node script, reference the extension. Note that VS Code sees this as valid.
  3. In the editor, play the game.

EDIT: I did more research and it looks like that Godot neglects to include .cs files in the solution that do not contain nodes. This is undesirable.

@11clock 11clock changed the title Build Does Not Detect C# Extensions Build Does Not Detect C# Extensions (or any .cs files that do not contain nodes) Dec 22, 2017
@groud groud added this to the 3.0 milestone Dec 22, 2017
@neikeq
Copy link
Contributor

neikeq commented Dec 22, 2017

I assume you created it from VS Code, which does not update the csproj. Godot cannot assume the file is part of the game csproj (you could have other C# projects). Godot only makes this assumption when creating the script from the Godot editor, when the script is attached to a node and when the script is used as an AutoLoad (this last one is pending 😄).

You must either create the script from Godot or use an IDE like MonoDevelop or Visual Studio. EDIT: Found this VS Code extension: https://marketplace.visualstudio.com/items?itemName=lucasazzola.vscode-csproj

BTW, I plan to add a panel to view and edit includes and references in the game project, in order to make it friendlier than editing the project file. This will happen after 3.0 though.

@akien-mga
Copy link
Member

We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth.

@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 5, 2018
@11clock
Copy link
Author

11clock commented Jan 6, 2018

The VS code extension is a decent workaround until then, although not perfect. I can wait.

@11clock
Copy link
Author

11clock commented Jun 27, 2018

Are there any updates on this issue?

@exts
Copy link
Contributor

exts commented Jun 27, 2018

@neikeq can you update the title of this issue to reflect the actual issue since c# extensions actually work fine with godot. This is a file being included in the csproj file issue w/ vscode/godot editor. Which is a non issue in most IDE's.

@PJB3005
Copy link
Contributor

PJB3005 commented Jul 2, 2018

I can't say I've tested this, but a workaround for this, although kinda hacky, is to add the following line before the </Project> in your .csproj file:

<ItemGroup>
  <Compile="**\*.cs" />
</ItemGroup>

This should make msbuild automatically compile all .cs files without having to manually add them to the .csproj, so kinda like a .NET Core project.

You can also Make it only do specific directories by making <Compile> entries for specific folders, probably: <Compile="src\**\*.cs" />

@neikeq
Copy link
Contributor

neikeq commented Jul 3, 2018

I guess the best will be to watch the project directory for source files added or removed outside the Godot editor and show a dialog asking for confirmation from the user to apply these actions to the project.

@akien-mga
Copy link
Member

Related to #12917.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Feb 23, 2019
@nuke-haus
Copy link
Contributor

nuke-haus commented Feb 27, 2019

Might be worth adding some sort of Godot option to generate the csproj with the wildcard to grab all C# files. I know i've been struggling with my csproj sometimes missing files, i'd have certainly opted for something more automated if given the option.

Unity does that thing where it rebuilds the csproj when it detects a new script in the project dir, maybe Godot doesn't need to go that far though.

@phelioz
Copy link

phelioz commented Nov 17, 2019

I can't say I've tested this, but a workaround for this, although kinda hacky, is to add the following line before the </Project> in your .csproj file:

<ItemGroup>
  <Compile="**\*.cs" />
</ItemGroup>

This should make msbuild automatically compile all .cs files without having to manually add them to the .csproj, so kinda like a .NET Core project.

You can also Make it only do specific directories by making <Compile> entries for specific folders, probably: <Compile="src\**\*.cs" />

Worked great for me :) But had to change it to following to get the project to compile.

<ItemGroup>
    <Compile Include="**\*.cs" />
</ItemGroup>

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Nov 26, 2019
@aaronfranke
Copy link
Member

Please re-test with Godot 3.2.3 and/or the master branch. Both of these use the new C# project format, so issues related to the csproj file might just not exist anymore. Also, check if you have the latest Mono and .NET Core.

As of Godot 3.2.3, using this as your csproj should automatically include every C# file:

<Project Sdk="Godot.NET.Sdk/3.2.3">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>
</Project>

If this issue does still exist for you, then you will need to include a minimal reproduction project.

@Tobi-Mob
Copy link

Please re-test with Godot 3.2.3 and/or the master branch. Both of these use the new C# project format, so issues related to the csproj file might just not exist anymore. Also, check if you have the latest Mono and .NET Core.

As of Godot 3.2.3, using this as your csproj should automatically include every C# file:

Works for me in Godot 3.3.3 as you said.
A new Godot project uses the new csproj format which does not has this issue.

@Calinou
Copy link
Member

Calinou commented Sep 10, 2021

Closing as resolved per @Tobi-Mob's comment. Thanks for testing 🙂

@Calinou Calinou closed this as completed Sep 10, 2021
@Calinou Calinou modified the milestones: 4.0, 3.3 Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests