Run NPM (Or Any Other) Scripts Before Build With ASP.NET
Run any script you want (in this case NPM) before a build in ASP.NET Core.
Sometimes, you might need to run a certain script before build in ASP.NET Core. This can easily be done in the
.csproj folder. You can run any script you want, but in this case, I’ll use an example with
The only thing you need to do is to add a
target to your
.csproj file. It looks something like this:
<Target Name="GetTranslations" BeforeTargets="Build"> <Exec WorkingDirectory="$(SpaRoot)" Command="npm run translations" /> </Target>