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

Fixed VS 2022 Mac compatibility #81802

Merged
merged 1 commit into from
Sep 22, 2023
Merged

Conversation

Nomad1
Copy link
Contributor

@Nomad1 Nomad1 commented Sep 17, 2023

Visual Studio 2022 on Mac marks the project as invalid if the project Guid is set. The easiest way to fix it is to add an additional check and disable 'EnableGodotProjectTypeGuid' for the SDK when the Visual Studio version is less than 17.0.

Bugsquad edit:

@RedworkDE
Copy link
Member

See also the issue about this: #67029
How does this PR behave in regard to the SDK issues and Godot plugin mentioned there?
Is there a better way to detect VS for mac? If not what are the consequences of removing that GUID for VS 2019 and earlier on windows?

@RedworkDE RedworkDE added cherrypick:4.0 cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Sep 17, 2023
@Nomad1
Copy link
Contributor Author

Nomad1 commented Sep 17, 2023

See also the issue about this: #67029 How does this PR behave in regard to the SDK issues and Godot plugin mentioned there? Is there a better way to detect VS for mac? If not what are the consequences of removing that GUID for VS 2019 and earlier on windows?

It fixes the abovementioned issue for VS 2022 Mac. Restoring the Nuget projects makes VS 2022 fully working, even without the Godot Addin (Addin could not be fixed ATM since there is no recent version of MonoDevelop.AddinMaker).
The condition allows it to work with VS 2019 Mac but I can't check the earlier versions.
Will re-check it on Windows tomorrow and maybe add one more condition to avoid issues there.

@Nomad1
Copy link
Contributor Author

Nomad1 commented Sep 18, 2023

Test results.

Mac

[-] VS 2017: broken, might work if addin is installed

  • addins are not working anymore - repository is down
  • .NET SDK 6.0 and 7.0 detected in corresponding folders
  • project is not opening when ProjectTypeGuid is set, removing it allows the project to open
  • Godot libraries are not resolved
  • can't compile, unknown error

[*] VS 2019: broken on M1 might work on Intel

  • addin is installed and working
  • .NET SDK 6.0-7.0 cannot be found on M1
  • project is opening, regardless of ProjectTypeGuid
  • Godot libraries are not resolved on M1
  • can't compile on M1

[+] VS 2022: works

  • addin could not be installed, major compatibility issues
  • SDK detected
  • project is opening only if ProjectTypeGuid is disabled
  • Godot libraries are resolved after Nuget Restore
  • compiles without any issues

[+] VS Code: works

  • addin works
  • SDK detected
  • project always opens (you can't break it, it works on folder level not with the .csproj)
  • Godot libraries are resolved
  • compiles with MSBuild, can fail if no .NET SDK is installed

Windows

[-] VS 2019: doesn't support .Net 6.0 even with Preview Features hack

  • no addin available for Godot 4.x and VS 2019
  • .NET SDK installed and MSBuild sees it, but not the Visual Studio
  • project is opening regardless of ProjectTypeGuid
  • Godot libraries are downloaded with Nuget but not loaded
  • doesn't compile

[+] VS 2022: works

  • addin not in the repository, haven't checked the one from the github
  • SDK detected
  • project is opening every time
  • Godot libraries are resolved
  • compiles without any issues

[+] VS Code: works

  • addin works
  • SDK detected
  • project always opens (you can't break it, it works on folder level not with the .csproj)
  • Godot libraries are resolved
  • compiles with MSBuild, can fail if no .NET SDK is installed

** Conclusion **
Since migrating from Mono to .Net 6+ we are restricted to MSBuild project types and the latest Visual Studio versions that don't rely on ProjectTypeGuid but sometimes fail if it's invalid. There is literally zero need for it anymore for the 4.x branch. Visual Studio Code is the main future target for Godot C# development and is not affected by the .csproj files at all.
I vote to remove the EnableGodotProjectTypeGuid or force it to false without any extra condition.

@raulsntos
Copy link
Member

The ProjectTypeGuid has already been removed in 3.x (see cd339ff), the reasoning was:

The property has no effect as the older VS project system doesn't
work with Sdk style projects.

The presence of the property was preventing Visual Studio for Mac
from opening the project if the Godot extension is not installed.

So I think it makes sense to remove it altogether.

@Nomad1
Copy link
Contributor Author

Nomad1 commented Sep 21, 2023

The ProjectTypeGuid has already been removed in 3.x (see cd339ff), the reasoning was:

The property has no effect as the older VS project system doesn't
work with Sdk style projects.
The presence of the property was preventing Visual Studio for Mac
from opening the project if the Godot extension is not installed.

So I think it makes sense to remove it altogether.

Removed and committed new code.

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Sep 21, 2023
@raulsntos
Copy link
Member

You'll have to remove <GodotProjectTypeGuid> from Sdk.props as well (see the linked commit cd339ff).

Also, you'll need to squash the commits before this PR can be merged. The contributing documentation contains information about squashing in case you need it.

Feel free to reach out in the development chat if you need help.

Visual Studio 2022 on Mac marks the project as invalid if the project Guid is set. Easiest way to fix it is to remove outdated 'EnableGodotProjectTypeGuid' and other Guid references
Copy link
Member

@raulsntos raulsntos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@akien-mga akien-mga merged commit d65d379 into godotengine:master Sep 22, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉

@Nomad1 Nomad1 deleted the vs2022_mac_fix branch September 22, 2023 20:07
@akien-mga
Copy link
Member

Cherry-picked for 4.1.2.

@akien-mga akien-mga removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release topic:buildsystem labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visual Studio can't open Godot 4 C# solution on Mac OSX 12.5
5 participants