Development Server hot updates not working - visual-studio-2017

I upgraded my .NET Core 2.1 project to Angular 6 and everything seems to be working correctly except for hot-updates. Before updating it was possible to update the TypeScript and VS would re-compile and reload the browser, now that seems to be broken along with having to manually run ng build to recompile the scripts, VS doesn't seem to recompile automatically anymore.
Is there a setting, possibly in angular.json that I need to set to enable the development server?
Update
For some reason, Hot Updates started working temporarily and not sure what I did to get it to start/stop working. When I start a debug session and update any of the .ts files, I can see the compiler output succeeding but when I refresh my browser I don't see any of the changes unless I manually build the project using the ng build.
I am starting to think that there is some miscommunication going on somewhere or possibly an error somewhere that isn't being picked up by the compiler causing something not to update?
Another thing I noticed while watching my output window is my site starts running on localhost:44359 but in the output, it says Angular Live Development Server is listening on localhost:55287 should these ports match?
one last observation I have made is after a change has been made during a debug session the output window lists all the chunks just like when running it manually with the exception it outputs i 「wdm」: Compiled successfully could something be corrupt or is this simply an output bug?

After a ton of messing around, I finally got this working and thought I would share what is going on.
When you run ng build it compiles and outputs to the ClientApp/dist folder. When you start the Debug Session your project uses this version. If you change a file at runtime it will re-compile the files but it will not overwrite the compiled files in the dist directory. I think because the files were manually generated outside of the UI, VS thinks it can not overwrite them.
So if you start running into this same problem luckily there is an easy fix, simply delete the ClientApp/dist folder before you start the Debug Session. Visual Studio will compile the files in the background and when you update a source file or style sheet your browser should refresh automatically.
Update
Another thing I found is if you need to manually run ng build there is another way to keep the files up-to-date at least (requiring reload):
package.json
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"debug": "ng serve --watch",
},
Then run ng build --watch instead of ng build this will put the prompt into a watch mode (press ctrl c to end), then every time you change one of the source files it will update. I added the "debug" because I wasn't sure if it would mess with the production, always safe to keep things existing or default if you can as a backup.
Then in Startup.cs (Configure(…)) update the server to use the new "debug":
spa.UseAngularCliServer(npmScript: "debug");
Update - 2
Another thing that I have found when using Angular and VS (2017) is if you happen to have an error somewhere in your code that isn't picked up by the cli compiler, especially in any of the constructors or ngOnInit() functions, it will hang up the Angular Service even after shutdown, making it seem like the hot-updates are no longer working. This will lead to complete Madness because none of the changes or updates will be loaded until the service is shutdown.
Another possible cause are errors when compiling .scss or Angular. Check the "Output" window for any Angular-cli Errors or in the Browsers Output.
After shutting down VS, make sure that VSCompiler.exe, any extra Console Windows Host (Angular Server, not the one running under the SQL User i.e. MSSQLFDLauncher... ) and any Visual Studio services are shutdown in your Task Manager.
I realized that it was actually an ERROR in MY CODE that was causing everything to stop working or not work at all. Angular and .NET will NOT always throw an error, sometimes the errors are simply skipped (especially when there are syntax errors) or output in the midst of all the other outputs.
More than likely if things stop working, it is either because of an error or some other reason that caused the compiler to stop responding. One last area to double check are your package.json and angular.json, especially any paths, then run the following and keep an eye on the output for updates that need to be made:
ng update
npm update
npm rebuild
npm install
The default .json files should work right out of the package, try to revert back to those to check your configuration. Deleting the dist folder basically is a shortcut for the above (minus the actual output, let VS compile before Debug), forcing angular to recompile everything but keep in mind that if the service is hung up, it won't matter what you do until that service is stopped.

Short answer.
Delete 'Dist' folder in ClientApp folder. in VisualStudio
and Reboot and Run

I have passed trought the same problem.
You have two options:
Delete the "dist" folder(this folder will be recreated everytime you use 'ng-build')
Make the implementation equals the link below. This implementation makes the application ignore the dist folder. It will only be used at production environment.
Implementation
I think the second solution is better, because you don't have to delete the "dist" folder everytime you want to debug your application.

Related

Update server with unsynched file from VS

I code in C++ with VS19. I debug on a remote machine (specifically a docker container), which means that my IDE copies the changed files whenever I hit the debug button and build the program in the target.
My remote machine isn't stable and sometimes it restarts and reverts to the initial state of my image.
When it does, I usually have files on the IDE that have been already copied to the remote machine before. When I start debugging, my IDE thinks there is nothing to update the server, and executes the program remotely. The thing is that the files on the remote are outdated and then my debug is showing wrong lines and an outdated version is executed.
The only solution I have found so far it to do a minor change in all the files that I remember that I have changed, which in turn tells the IDE to update those files on the remote.
This is really hard and sometimes files are missed.
I have found nothing about it online, will be glad to hear if someone tackled this problem.

Is there any way to run a batch file as a post build event in VS which is opening an app?

SUMMARIZE THE PROBLEM:
I'm using Visual Studio 2015 for some project and what I'm trying to do is to run a batch file which is going to open an app(whatever app). The problem is that the VS2015 is going to get stuck in the build process until my app is going to be close.
The batch is working perfectly fine. You could try this just with a batch something like:
start notepad.exe
Or whatever you want, it doesn't really matter what's the application you are going to open here.
WHAT I'VE TRIED:
I've tried already some alternatives like...
Run the bat from the post-build event with "call", "start" or with none of them.
I've added "exit 0" on the end of the file(batch)
Also, I've tried to create 2 batch files. One was the original one and the second one was calling the first one. So I've added the second one at the post-build event. Nothing changes, of course.
WHAT I AM TRYING TO OBTAIN:
On the end, all that I'm trying to obtain is just a batch with is going to open an application after the build/rebuild of the project is done without getting stuck somewhere there.
It's going to stay in this "Build" process even though the build is "Build Succeed"
Unfortunately I believe all processes spun off by the build have to be joined and returned successfully for VS to consider the build a success. Instead, is it possible in your use-case to attach the batch file to the execution step of your project? In the project settings you can modify the command line arguments to spin off your batch file before executing your project executable. Is there any issues with this approach?
I found this too, would this help: Visual Studio post build events stuck waiting for executable to finish before running app in debug mode

How to never be prompted to run last successful build when unit testing

I want to get rid of the dialog saying
There were build errors. Would you like to continue and run tests from
the last successful build
when I am running unit tests (I use test -> run -> all tests).
How do I do that? I already know how to disable it when running a normal project.
I also want to know how this can ever be a useful feature?
How do I do that?
You can't.
I also want to know how this can ever be a useful feature?
I find it useful when I am working closely with someone who is configuring test data. I can re-run tests to ensure new test data is valid, without having to worry about compiling any changes that I have done in the meantime.
For example if someone has changed some data in a database, I want to be able to run my tests to ensure that this new data is valid, and I want to be able to run the tests whether the current state of my code compiles or not.
For Visual Studio 2017 / MSTestV2 you can do:
Tools > Options > Project and Solutions > Build and Run
"On Run, when build or deployment errors occur:" "Do not launch"

How to cleanup CommitLog files using Cassandra in Unit Tests

I've got a problem that's very similar to the one listed here:
How to cleanup embedded cassandra after unittest?
In short, I'm firing up Cassandra to run some integration tests, but when my test classes run they fail as they are unable to delete the CommitLog files that are produced by Cassandra.
I'm following the suggestions in the answer given there, which are to perform cleanup on startup, but at that time the files still cannot be deleted (if I debug through the code, I am also unable to delete the files at that time via the command line or the GUI). The result is that my first test class passes, but all subsequent ones fail.
Further details:
My colleagues are running on OSX and do not have this problem; I am on Windows 7.
I've tried running the tests under DOS and Cygwin, as well as through Eclipse, in all cases both as my local user and as Administrator.
I've used Process Explorer to confirm that nothing apart from a single Java process has a handle on the file in question.
I've debugged through the code right down to the native call in java.io.Win32FileSystem, which is unable to delete the file.
Is there anything I can do to ensure Cassandra has shut down and/or deleted its CommitLog file?
Thanks!

Eclipse/PyDev + Django debug

Eclipse/PyDev, Python 2.6, Django 1.1
All is working in run mode. If I put debug point inside manage.py file, breakpoint worked. But when I putted it in any action method, it causes nothing :(
Usually the problem is that you're running with auto-reload in django, in which case a different process is actually feeding the pages, so, you need to run it with the no reload option or use the remote debugger.
(To configure PyDev to work with Django see: http://pydev.org/manual_adv_django.html)
Note that if you want to execute without the auto-reload feature (which PyDev should do automatically when you create a new Django run), you can do all directly (i.e.: the debugger and launching don't need any special adjustments).
Note: the situation has improved a bit recently, so, although the above answer is still valid, there are improvements for those that do want to develop with auto-reload on:
Answer with auto-reload on:
If you want to have auto-reload on while developing, use the tips at: PyDev and Django: how to restart dev server? (to overcome an issue where Django will leave child processes alive when the main process is killed)
And see the session related to the remote debugger at: http://pydev.org/manual_adv_remote_debugger.html to see how to attach the debugger to PyDev when using the auto-reload feature (mainly, you'll need to start the remote debugger, but will add breakpoints regularly and PyDev will stop on those provided you call pydevd.patch_django_autoreload() before you main session -- i.e.: before if __name__ == "__main__":, add the following: import pydevd;pydevd.patch_django_autoreload()).
also if while attempting to import pydevd eclipse can't find the pydevd depependency. Make sure to add it from your plugins folder:
Look for your eclipse/plugins/org.python.pydev_x.x.x/pysrc where x.x.x is your eclipse pydev plugin version. In the eclipse/plugins folder you will find lot's of folders that start with a similar name only one of them will have a pysrc subfolder(and the right version number).
Add eclipse/plugins/org.python.pydev_x.x.x/pysrc to your project's external libraries:
Right click on your project explorer.
Go to properties/PyDev - PYTHONPATH/External Libraries/ and click on Add Source folder.
Find your eclipse/plugins/org.python.pydev_x.x.x/pysrc folder on the provided browser.