0

I have an existing ASP.NET MVC 5 project that I will be retrofitting to use Angular. Using a new ASP.NET Core project with the Angular template, I've been able to configure the spa services so that it runs properly.

The problem I'm running into is that the Angular app doesn't build properly when you run the ASP.NET MVC app. If I run a ng build before running the ASP.NET MVC app, everything comes up just fine.

But when it's just the ASP.NET MVC build, typescript compiles, but it doesn't run ng build. I've tried putting the commands in prebuild with no luck.

Any suggestions on where to go from there would be appreciated, thanks!

1 Answer 1

1

Try add this into web config.

<Target Name="Build Angular Debug" Condition="'$(Configuration)'=='Debug'" BeforeTargets="Build">
    <Message Text="* * * * * * Building Debug Angular App * * * * * *" />
    <Exec Command="ng build" />
</Target>

FINAL OP EDIT by comments

<Target Name="Build Angular Debug" Condition="'$(Configuration)'=='Debug'" BeforeTargets="Build">
    <Message Text="* * * * * * Building Debug Angular App * * * * * *" />
    <Exec Command="ng build" WorkingDirectory="$(ProjectDir)ClientApp" />
</Target>
Sign up to request clarification or add additional context in comments.

2 Comments

are you referring to web.config? Or the project file? I thought <Target> tags belonged in the project config file...
So this did solve the problem, the only change I had to make was to specify the working directory on the exec command, since the angular app was in a subdirectory on the project, ng build couldn't find the app till I did that. The final exec statement looked like this: <Exec Command="ng build" WorkingDirectory="$(ProjectDir)ClientApp" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.