Run NPM (Or Any Other) Scripts Before Build With ASP.NET
1 min read

Running scripts

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 npm.

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>