dotnet/aspnetcore

Support pnpm that installed using a standalone script in SpaProxyLaunchCommand

Open

#45.700 geöffnet am 21. Dez. 2022

Auf GitHub ansehen
 (5 Kommentare) (3 Reaktionen) (0 zugewiesene Personen)C# (10.653 Forks)batch import
area-ui-renderingfeature-spagood first issuehelp wanted

Repository-Metriken

Stars
 (37.933 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 16T 9h) (258 gemergte PRs in 30 T)

Beschreibung

Given a ASP.NET project with SPA setup:

  <PropertyGroup>
    <SpaRoot>client-app\</SpaRoot>
    <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
    <SpaProxyServerUrl>https://localhost:5173</SpaProxyServerUrl>
    <SpaProxyLaunchCommand>pnpm dev</SpaProxyLaunchCommand>
  </PropertyGroup>

SpaProxyLaunchManager failes to launch SPA development server, saying it cannot find 'pnpm.cmd':

info: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
      No SPA development server running at https://localhost:5173 found.
fail: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
      Failed to launch the SPA development server 'pnpm dev'.
      System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'pnpm.cmd' with working directory 'C:\project\client-app\'. 지정된 파일을 찾을 수 없습니다.
         at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
         at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
         at Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager.LaunchDevelopmentProxy()
fail: Microsoft.AspNetCore.SpaProxy.SpaProxyLaunchManager[0]
      Couldn't start the SPA development server with command 'pnpm dev'.
info: Microsoft.AspNetCore.SpaProxy.SpaProxyMiddleware[0]
      SPA proxy is not ready. Returning temporary landing page.

It makes sense because, using a pnpm installation standalone script, we do not have pnpm.cmd, but only pnpm.exe at %localappdata%\pnpm\.

I know I can use pnpm modifying SpaProxyLaunchCommand to have the extension like pnpm.exe dev,

https://github.com/dotnet/aspnetcore/blob/589aa11b5c631ce719e0530d66be8324a6d79169/src/Middleware/Spa/SpaProxy/src/SpaProxyLaunchManager.cs#L169-L174

but it would be great if we could omit it.

Contributor Guide