Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When running an ASP.NET Core 6 project that uses SPA proxying, an error is logged to the console during startup:
info: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
No SPA development server running at https://localhost:44408 found.
'path/to/project/.../bin/Debug/net6.0/a447c16478b24b5c85fd2b88ca706735.sh: line 1: syntax error near unexpected token `{
'path/to/project/.../bin/Debug/net6.0/a447c16478b24b5c85fd2b88ca706735.sh: line 1: `function list_child_processes(){
From what I can tell, this is happening because the shell script that's generated by the SpaProxyLaunchManager uses CRLF line endings, whereas bash on macOS (and presumably any *nix OS?) only supports LF line endings. If I change the file to use LF line endings, I can manually run the script without encountering a syntax error.
Expected Behavior
I expect the SPA proxy stop script to run without encountering syntax issues. Presumably, this should be fixed by ensuring the generated shell script uses LF instead of CRLF line endings.
Steps To Reproduce
- Create an ASP.NET Core 6 with React.js project from a template
- Start the project
- Look at the output logged to the console during startup
I don't know if it's relevant, but I created the project in IntelliJ Rider. As far as I'm aware though, Rider is just directly using templates that are provided by dotnet.
Exceptions (if any)
No response
.NET Version
6.0.101
Anything else?
- Microsoft.AspNetCore.SpaProxy 6.0.1
- IDE: JetBrains Rider 2021.3.2
- macOS 11.6.2
The code that generates this script was introduced by #35591 and can be found here:
aspnetcore/src/Middleware/Spa/SpaProxy/src/SpaProxyLaunchManager.cs
Lines 250 to 291 in 2a2f285
| private void LaunchStopScriptMacOS(int spaProcessId) | |
| { | |
| var fileName = Guid.NewGuid().ToString("N") + ".sh"; | |
| var scriptPath = Path.Combine(AppContext.BaseDirectory, fileName); | |
| var stopScript = @$"function list_child_processes(){{ | |
| local ppid=$1; | |
| local current_children=$(pgrep -P $ppid); | |
| local local_child; | |
| if [ $? -eq 0 ]; | |
| then | |
| for current_child in $current_children | |
| do | |
| local_child=$current_child; | |
| list_child_processes $local_child; | |
| echo $local_child; | |
| done; | |
| else | |
| return 0; | |
| fi; | |
| }} | |
| ps {Environment.ProcessId}; | |
| while [ $? -eq 0 ]; | |
| do | |
| sleep 1; | |
| ps {Environment.ProcessId} > /dev/null; | |
| done; | |
| for child in $(list_child_processes {spaProcessId}); | |
| do | |
| echo killing $child; | |
| kill -s KILL $child; | |
| done; | |
| rm {scriptPath}; | |
| "; | |
| File.WriteAllText(scriptPath, stopScript); | |
| var stopScriptInfo = new ProcessStartInfo("/bin/bash", scriptPath) | |
| { | |
| CreateNoWindow = true, | |
| WorkingDirectory = Path.Combine(AppContext.BaseDirectory, _options.WorkingDirectory) | |
| }; |
Activity
rpendleton commentedon Jan 2, 2022
It looks like I only searched issues and open pull requests, so I missed a related pull request that has been closed: #38293.
With that said though, that PR was closed instead of merged, and the proposed fix wouldn't have actually fixed the issue. The change in the PR was to add a space to the first line of the script, but when I add a space to the file, it doesn't actually fix the issue. The only way I was able to fix the issue was by changing the line endlines from CRLF to LF.
I'm not sure what to do with this issue now. The related PR mentions that fixing this isn't a priority since it's not customer facing yet. However, I'm just a normal developer and, as far as I'm aware, am only using stable channels for dotnet. I don't know if anything has changed in the last few weeks, but the issue seems to be customer facing to me.
Perhaps someone that's more familiar with the .NET release schedule can clear things up for me?
isebasus commentedon Feb 3, 2022
Any updates?