是否可以在不包含整个node_modules
文件夹的情况下,将NodeJS / Npm依赖项捆绑到Nuget包中?我正在寻找一个安装后挂钩,当用户安装软件包时,将自动触发命令以在相应文件夹中运行npm install
。 Nuget / C#中是否存在类似的东西?还是我最好将它们全部编译成一个文件,然后在项目中使用它(通过NodeServices)?
答案 0 :(得分:1)
我认为您无法做到这一点,但是当您通过像这样编辑csproj文件来构建解决方案时,有一种方法可以运行npm install
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '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 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>