ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.28k stars 748 forks source link

Source Generator Doesn't Handle Spaces in Project Paths #5552

Closed evan-buss closed 1 year ago

evan-buss commented 2 years ago

Is there an existing issue for this?

Describe the bug

I am trying to generate a GraphQL client with StrawberryShake and the source generation fails on dotnet build. The project path is nested within a folder called Visual Studio 2022 which seems to be the issue. When I move the entire project to a path without any space characters it works correctly.

I believe this is an issue with the CLI library based on the stack trace. When I run the source generator manually via dotnet graphql generate it works correctly.

Is there any way to disable the automatic source generation on build so I can continue development in the meantime?

Steps to reproduce

  1. Initialize a new .NET Core application at a file path with a space character (ex. ~/Downloads/bad path/
  2. Install StrawberryShake.Server. (<PackageReference Include="StrawberryShake.Server" Version="13.0.0-preview.80" />)
  3. Initialize with any GraphQL service (follow tutorial).
  4. Run dotnet build.

Relevant log output

PS C:\Users\busse\Documents\Visual Studio 2022\Project> dotnet build
MSBuild version 17.4.0+18d5aef85 for .NET
  Determining projects to restore...
  Restored C:\Users\busse\Documents\Visual Studio 2022\Project\MyProject.csproj (in 304 ms).
  Specify --help for a list of available options and commands.
  Unhandled exception. McMaster.Extensions.CommandLineUtils.UnrecognizedCommandParsingException: Unrecognized command o
  r argument 'Studio'
     at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.ProcessUnexpectedArg(String argTypeName, String argVa
  lue)
     at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.ProcessNext()
     at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.Process()
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Parse(String[] args)
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cance
  llationToken)
     at StrawberryShake.Tools.Program.<Main>(String[] args)

Additional Context?

No response

Product

Strawberry Shake

Version

13.0.0-preview.80

sunghwan2789 commented 2 years ago

Temporary workaround is as follows:

  1. go NuGet packages cache directory
  2. open strawberryshake.server/13.0.0-preview.80/build/StrawberryShake.Server.targets
  3. find red lines and patch them:

    @@ -27,9 +27,9 @@
    
     <PropertyGroup>
       <GenCommand>dotnet &quot;$(GenTool)&quot; generate &quot;$(MSBuildProjectDirectory)&quot;</GenCommand>
    -      <GenCommand>$(GenCommand) -o $(GraphQLCodeGenerationRoot)</GenCommand>
    +      <GenCommand>$(GenCommand) -o &quot;$(GraphQLCodeGenerationRoot)&quot;</GenCommand>
       <GenCommand Condition="'$(RootNamespace)' != ''">$(GenCommand) -n $(RootNamespace)</GenCommand>
    -      <GenCommand Condition="'$(GraphQLPersistedQueryOutput)' != ''">$(GenCommand) -q $(GraphQLQueryGenerationRoot)</GenCommand>
    +      <GenCommand Condition="'$(GraphQLPersistedQueryOutput)' != ''">$(GenCommand) -q &quot;$(GraphQLQueryGenerationRoot)&quot;</GenCommand>
       <GenCommand Condition="'$(GraphQLRequestHash)' != ''">$(GenCommand) -a $(GraphQLRequestHash)</GenCommand>
michaelstaib commented 2 years ago

Do you want to do a PR? I can guide you through if you need help.