godot icon indicating copy to clipboard operation
godot copied to clipboard

C#: Fix building projects for MSBuild before 17.3

Open RedworkDE opened this issue 3 years ago • 6 comments

  • 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
    • \n and \r because 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~
  • ~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.

RedworkDE avatar Mar 06 '23 11:03 RedworkDE

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)

RedworkDE avatar Mar 06 '23 14:03 RedworkDE

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?

raulsntos avatar Mar 06 '23 15:03 raulsntos

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?

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.

RedworkDE avatar Mar 06 '23 15:03 RedworkDE

We can add ' to the blacklist, and then if users report other characters being problematic we can add them when they are reported.

raulsntos avatar Mar 06 '23 15:03 raulsntos

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.

RedworkDE avatar Mar 06 '23 16:03 RedworkDE

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.

RedworkDE avatar Mar 06 '23 17:03 RedworkDE

Thanks!

akien-mga avatar Mar 06 '23 19:03 akien-mga

Cherry-picked for 4.0.2.

YuriSizov avatar Mar 27 '23 15:03 YuriSizov