I have followed the steps outlined in this so post, and have successfully created a React Application inside Visual Studio from the "Blank Node.js Web Application".
Everything works except debugging from VS!
I have also followed this Microsoft article here which describes exactly what I want to do!!! - It walks you through "how to setup a react app in Visual Studio using the node web app template". On that article they show debugging working, but it doesn't work for me.
I am using the standard npm command to create an application inside the visual studio solution directory. I have created myself a batch file that does the heavy lifting for me.
npx create-react-app ssm-app --typescript
At this point, everything works fine and I can even interact with the NPM packages from inside VS.
I have even installed NPM Task Runner inside Visual Studio which allows you to run the commands (such as Start) from the package.json.
Everything works except debugging from inside Visual Studio!
I have then attempted to wire up the "Start Debugging" button in VS to attach it the npm start
command.
I did that by adding by finding this Microsoft article on how to extend the build process. I added the following code to the project file which works can calls npm start for me.
</ProjectExtensions>
<Target Name="AfterBuild">
<Exec Condition="'$(EnableTypeScript)' == 'true'" Command="npm start" />
</Target>
</Project>
It kinda works and does kick off a web browser and launch the app but Visual Studio toolbar just hangs. I think this is because npm start
hasn't exited. I have tried changing the command to call npm start
but it still hangs to toolbar.
Usually when you launch the debugger, the toolbar changes and you can see the stop button like below. That never happens
Any help would be greatly appreciated. Am I doing something wrong or am I approaching this from the wrong angle?
Thanks