0
votes

Have a .NET Core 2.2 app within a solution and have been using a publish profile to publish to a dev server. Now, Ive setup a Devops build pipleline to publish using a self-hosted agent on-prem. Mostly working but I can't see to get the npm build configuration right.

When I use my publish profile locally, Im using settings in the csproj file to control which options to use for npm build.

eg.

  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <!-- Use conditional builds based on build target setting eg.  debug, dev, prod etc -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build " Condition=" '$(Configuration)' == 'Debug' " />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --prod false --configuration=dev" Condition=" '$(Configuration)' == 'Test' " />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build --prod true --configuration=prod" Condition=" '$(Configuration)' == 'Release' " />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build:ssr --configuration=prod" Condition=" '$(BuildServerSideRenderer)' == 'true' And  '$(Configuration)' == 'Release' " />

However, npm build within my build pipeline isnt run until the publish step. And then its the default "ng build" with no settings to use the correct angular environment value.

On the npm build task I use this for a custom command

build --prod false --configuration=dev

but it doesn't seem to get run during the build.

How can I get the correct npm build settings to run?

My build pipeline looks like this enter image description here

1

1 Answers

0
votes

a) I had the same issue and I resolved this by updating the package.json file by adding a new command in the scripts(see attached image)

"build-staging": "ng build --configuration=staging"

Package.json

b) I also updated the Build Definition npm build

c) I deleted the exec lines in .csproj file under publishrunwebpack node e.csproj file

This resulted in running the correct nb build command based on the environment.