dotnet/aspnetcore

Support pnpm that installed using a standalone script in SpaProxyLaunchCommand

Open

#45,700 opened on 2022年12月21日

GitHub で見る
 (5 comments) (3 reactions) (0 assignees)C# (10,653 forks)batch import
area-ui-renderingfeature-spagood first issuehelp wanted

Repository metrics

Stars
 (37,933 stars)
PR merge metrics
 (平均マージ 16d 9h) (30d で 258 merged PRs)

説明

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.

コントリビューターガイド