How to automate the npm install, when you publish your .net core project,
and make sure the publish operation include the node_modules folder created
please follow the next steps to do this solution
and make sure the publish operation include the node_modules folder created
please follow the next steps to do this solution
- double click on the project or right click on the project and select edit, you will open .csproj file, you will find xml data
- exclude the node_modules from your project
- remove the ItemGroup which contains the reference the node_modules files
- write the following code
<Target Name="PostBuild" AfterTargets="ComputeFilesToPublish"> <Exec Command="npm install" /> </Target> <Content Include="node_modules/**" CopyToPublishDirectory="PreserveNewest" /> </ItemGroup> - finally run the publish command "dotnet publish -o c:\temp\publish"