Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxs-rose opened this issue Oct 29, 2024 · 0 comments
Open
Assignees
Labels
Area-esproj Issues related to the Javascript project system untriaged Request triage from a team member

Comments

@maxs-rose
Copy link

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>
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Oct 29, 2024
@baronfel baronfel added Area-esproj Issues related to the Javascript project system and removed Area-NetSDK labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-esproj Issues related to the Javascript project system untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants