-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Detect and update .csproj when C# files are added, moved or removed. #20287
Conversation
The problem with this is it will add every |
@neikeq Yeah, that's true. But is it such a big problem? How would you suggest fixing it? |
Same as @neikeq, solving it by regenerating the solution from scratch is a bad idea and must be handled with care, as I explained here #12415 (comment). To preserve the state of the solution, Godot should just do what it needs to do (aka add or remove files), not recreate it all. |
@Zylann But this is not overriding the solution really. It only removes the |
I could be missing something though. |
@Nufflee if it only adds or remove files that's fine, but as @neikeq said it could conflict with other C# projects within the Godot project. On a side note I wonder if editor-only assemblies were considered yet, but those would typically be in different projects as well (unless Godot does something special). |
@Zylann @neikeq What Unity does to solve this issue is that they only allow 3 (or 4 but doesn't really matter) assemblies per project with each one of them being in a special directory. We should probably do this though it limits the number of game assemblies. We can somehow map assemblies to directories to know which |
@Nufflee Marking folders for custom projects can also be a solution indeed. |
@Zylann From what I can see, the person in the article just let Visual Studio manage So the solution would be to, when a I hope this makes sense as it almost 4 AM. |
Last concern I just thought: walking the whole project can take a lot of time as it grows, so this should happen only if .cs files were added/removed, not at every build (incremental build could end up being faster than the scan). But I wonder if there is a way for the build system to know that. |
Unity created a new way of defining solutions around last November called assembly definition files. This allows you to place a definition asset within a directory and it will generate a solution for that directory. If there's another assembly def under that directory it will use that instead. Then, as options on the assembly defs you can define which platforms that solution should compile for such as: Editor Only, Windows, Mac, Linux, iOS, Android, etc. You can reference other assembly definitions on another assembly def in order to define dependencies. It's very straight forward and quite flexible. I wonder if there's some sort of hybrid approach, because I can see the need for wanting to have very meticulous access the the csproj and sln files, but I can also see this becoming a debugging nightmare due to using slightly incorrect settings. For instance, last I checked (it was a few months ago) we have to change 4 different things in order to simply change the name of a Godot game project in order for it to compile again. An auto-generated solution wouldn't have this problem at all. But, I suppose this is a conversation for another thread at another time, but I think it would be worth exploring down the road. IE. maybe having the sln/csproj files auto-generated by default, but we could override it by pointing it to a specific sln file in the project settings. |
@Zylann I'm not too sure how slow would it be but I made it walk to whole solution to also account for file system changes (basically those made from a code editor like VS Code even though this could also be quite easily handled on VS Code level but it's not the only code edtor people use so it wouldn't be a very universal solution). |
And yeah, @NathanWarden, you should probably open an issue for that. |
I'm also of the opinion that godot shouldn't be automatically screwing with the project files - leave that to IDEs which specialize in it. I think that updating the project file only when adding/removing/moving scripts via the godot editor itself makes more sense than doing a filesystem scan on build. The benefit is that when a user adds a script via the editor, it's fairly obvious that the intent is to add it to the godot project. When a file is added outside of the godot editor, it might be for something else entirely. |
As per the above discussion, it seems that this wouldn't be the proper solution to the original problem, so closing. Thanks nevertheless for the proposal and for the discussion it started! |
The .csproj file is updated when the C# solution is built to also account for changes outside the Godot editor. I also updated the .gitignore file to ignore .vscode directories in any directory, not just the root.
This closes #12917 and closes #12415.