4

I have an app generated with the angular-cli that is part of a Visual Studio 2015 solution. I would like to trigger a build

$(ProjectDir)_ng\ng build --prod

anytime the developer builds the other projects in the solution. I know this can be done using the pre-build event but I haven't had any luck with it so far. The command above is pasted directly from the event builder window. When I build currently I get an error that says ng isn't a recognized internal or external command. I installed the cli globally

npm install -g angular-cli

and if I put node -v into my pre-build event, I get the version information in the output window as expected.

Things I've tried:

If I use the command prompt shortcut from Web Essentials (alt+space) to launch cmd.exe from the angular project directory in Visual Studio, I can run ng build successfully.

If I put cmd.exe into the search bar in Windows 10 and run the "Command Prompt" desktop application that it finds, cd to the project directory and issue ng build it fails to run with the error

"'C:\dev\ph\git\BT2\bt2.web\_ng\ng' is not recognized as an internal or external command, operable program or batch file."
Mike Devenney
  • 1,758
  • 1
  • 23
  • 42

1 Answers1

1

Try

cd $(ProjectDir) ng build

To build with angular cli, you have to be in the folder where there is angular-cli.json file.