Skip to content

Support pnpm that installed using a standalone script in SpaProxyLaunchCommand #45700

@sunghwan2789

Description

@sunghwan2789

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,

if (OperatingSystem.IsWindows() && !Path.HasExtension(command))
{
// On windows we transform npm/yarn to npm.cmd/yarn.cmd so that the command
// can actually be found when we start the process. This is overridable if
// necessary by explicitly setting up the extension on the command.
command = $"{command}.cmd";

but it would be great if we could omit it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ui-renderingIncludes: MVC Views/Pages, Razor Views/Pagesfeature-spagood first issueGood for newcomers.help wantedUp for grabs. We would accept a PR to help resolve this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions