Skip to content

Ability to specify another package manager for JavaScript SDK projects #44516

Open
@maxs-rose

Description

@maxs-rose

Sorry if this is the wrong place but coming from this dotnet/aspnetcore#56111 discussion since the JavaScript.SDK currently isnt a public project.

Is your feature request related to a problem? Please describe.

An option to set a package manager other than npm when using Microsoft.VisualStudio.JavaScript.SDK for example pnpm. This would also be ideal if we want to specify any extra arguments for install such as being able to run npm ci condtionally for CI builds.

This would also potentially allow us to use deno.

Describe the solution you'd like

Much like the other properties in the esproj type it would probably be prefereable to have a similar interface to how the builds and start commands work.

<Project Sdk="Microsoft.VisualStudio.JavaScript.SDK">
    <PropertyGroup>
        <InstallCommand>pnpm install</ShouldRunBuildScript>
        <LockFile>pnpm-lock.yaml</LockFile>
    </PropertyGroup>
</Project>

Additional context

Currently there is a workaround for this by installing the SDK's .props and .targets outside of the <Project Sdk="Microsoft.VisualStudio.JavaScript.SDK"> and move it into <Import> to avoid the .targets being imported after the override due to Image

<Project>
    <!-- Cant be Project Sdk so we can control when things are imported -->
    <Import Project="Sdk.props" Sdk="Microsoft.VisualStudio.JavaScript.SDK" Version="1.0.1910670"/>
    <Import Project="Sdk.targets" Sdk="Microsoft.VisualStudio.JavaScript.SDK" Version="1.0.1910670"/>

    <PropertyGroup>
        <NpmInstallCheck>$(PackageJsonDirectory)pnpm-lock.yaml</NpmInstallCheck>
    </PropertyGroup>

    <Target Name="RunNpmInstall" Condition=" $(ShouldRunNpmInstall) == 'true' " DependsOnTargets="PreNpmInstallCheck" Inputs="$(PackageJsonDirectory)\package.json" Outputs="$(NpmInstallCheck)">
        <Exec Command="node --version" ContinueOnError="true">
            <Output TaskParameter="ExitCode" PropertyName="ErrorCodeNpmVersion"/>
        </Exec>
        <Error Condition="'$(ErrorCodeNpmVersion)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE."/>
        <Message Importance="high" Text="Restoring dependencies using 'pnpm'. This may take several minutes..."/>
        <Exec WorkingDirectory="$(PackageJsonDirectory)" Command="pnpm install">
            <Output TaskParameter="ExitCode" PropertyName="ErrorCodeNpmInstall"/>
        </Exec>
        <Touch Files="$(NpmInstallCheck)" Condition="'$(ErrorCodeNpmInstall)' == '0'" AlwaysCreate="true"/>
    </Target>
</Project>

Metadata

Metadata

Assignees

Labels

Area-esprojIssues related to the Javascript project systemuntriagedRequest triage from a team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions