C#: Fix building projects for MSBuild before 17.3
-
Fixes https://github.com/godotengine/godot/pull/74312#issuecomment-1455169861
-
Only pass the base64 path on compatible MSBuild versions
-
Emit a clear build error when using a path with special chars and an old msbuild
-
~Needs actually testing with an old msbuild~ works as expected.
-
Needs verifying the list of problematic chars:
- currently using
#and;because they are comment separators -
\nand\rbecause they are mentioned in the roslyn issue - ~
'is mentioned in the original issue, not sure why this is a problem, but I would guess string separator, so I added"as well~
- currently using
-
~Not sure what the sample is actually really used for (other than being a sample) so~ I would probably just keep it simple, so I left out the errors from there (and maybe would just remove the base64 path as well); still leaves the question if these things should be done to the sample.
A whole bunch of more testing shows that they are no problem. Also I removed the ' and " because I found that they are no problem when the appear in a folder name.
Instead I found that there is a whole separate issue of having these special characters in the project name and thus assembly name: While this all compiles without a problem the runtime, refuses to load assemblies with these characters in the name. This part is not resolved at all rn and needs its own fix (and escaping things won't help either)
Instead I found that there is a whole separate issue of having these special characters in the project name and thus assembly name
We should already be sanitizing the project name replacing all invalid characters with -, which results in the dotnet/project/assembly_name setting. Does this not resolve the issue?
We should already be sanitizing the project name replacing all invalid characters with
-, which results in thedotnet/project/assembly_namesetting. Does this not resolve the issue?
That list is missing at least '. but there is no explicit blacklist for these things so I am not sure what else should be added there.
We can add ' to the blacklist, and then if users report other characters being problematic we can add them when they are reported.
Some more guessing and checking later I found 4 chars not on the normal blacklist that cause issues, I just added that to this PR. This change wont help with existing project, but their csharp scripts are completely non-functional, even in the editor so there are probably not too many projects with them anyways.
I dropped the project name changes from this (as I probably should have from the beginning) and will open a new PR when that is ready.
Thanks!
Cherry-picked for 4.0.2.