jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers
Apache License 2.0
497 stars 50 forks source link

Bad command line in some cases when building fbs files #282

Closed shadowbane1000 closed 2 years ago

shadowbane1000 commented 2 years ago

I have a project that uses this kind of include path:

$(ProjectDir)

Sometimes, as a result of this, I get this error:

0>C:\Users\james.colbert.nuget\packages\flatsharp.compiler\6.2.0\build\FlatSharp.Compiler.targets(127,9): Error MSB3073 : The command "dotnet C:\Users\james.colbert.nuget\packages\flatsharp.compiler\6.2.0\tools\net6.0\FlatSharp.Compiler.dll --nullable-warnings true --normalize-field-names false --input "D:\Hexagon.Schema\WebSchemaFB\V1009\SceneGraph\Attributes.fbs" --includes "D:\Hexagon.Schema\WebSchemaFB\V1009\" --output obj\Debug\net6.0\" exited with code -1.

The issue is that the --includes argument is "D:\Hexagon.Schema\WebSchemaFB\V1009\", which ends with a \, which ends up escaping the close quote, which confuses the command line parser.

My temporary workaround is to change the include path to this:

$(ProjectDir).

By adding the "." to the end, the path no longer has the trailing backslach so the include path no longer escapes the closing quote and everything works fine.

On some files, with the trailing backslash, the compile does not issue the error, and I do not know why.

jamescourtney commented 2 years ago

Thanks for raising this! @yak-shaver, do you mind taking a look at this one? I think the answer is probably to trim any trailing \ characters in the targets file.

ghost commented 2 years ago

Sure, I'll take a look.

ghost commented 2 years ago

This was easy enough to reproduce in the sample project by adding a trailing backslash to the IncludePath property.

Agree with @jamescourtney that the best solution is to trim the trailing \ prior to calling the command line.

jamescourtney commented 2 years ago

Thanks @yak-shaver for submitting the fix. I've just completed the PR and will publish version 6.2.1 within the next day.

jamescourtney commented 2 years ago

6.2.1 is published!