Gulp recompilation of Less files restarts IIS Express in Visual Studio 2015 - less

I am using Visual Studio 2015 with Gulp which is watching for changes in my Less files. If a change is detected it compiles the Less files and creates the css for my application.
When the application is debugging in VS2015, and I modify my Less files causing a recompile of the css, IIS Express restarts my web application.
This causes a break in the work flow as it takes time to start up. I would not have expected this to happen as it doesn't normally when modifying plain css.
This happens whether I have it configured via the task runner or the command line.
Is there something I am doing wrong?
Update
After further digging, I have found that omitting:
gulp.task('clean-styles', function (cb) {
del([config.fontsout,
config.cssout,
config.lessout + '/*.css'], cb);
});
Seems to prevent IIS resetting every time I update css. I still don't know whether this is expected behaviour or if I am doing something else wrong?

Related

Razor Runtime Compilation breaks Hot Reload and therefore debugging in ASP.NET

Nomenclature
This question is about three related subjects that allow the developer to introduce code changes in a running application without having to rebuild and restart said application:
Edit and Continue: Visual Studio's functionality to modify assemblies that are being debugged. You can edit managed code while on a breakpoint (within some constraints), and it'll magically be applied to the debuggee.
Hot Reload: introduced with Visual Studio 2022, kind of like Edit and Continue, enabling runtime recompilation of managed code without having to be paused on a breakpoint or even having a debugger running to begin with.
Razor Runtime Compilation: editing Razor views of a running application, by recompiling them on save of a .cshtml file.
Setup
Visual Studio 2022 (17.4.4)
.NET 7 (SDK: 7.0.102) or 6 (SDK: 6.0.403)
NuGet: Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
The problems described below also occur on combinations of earlier versions of those components. Then:
Start Visual Studio 2022
Create an ASP.NET Core Web App running on .NET 6 or 7
Add the NuGet package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
Change the generated Program.cs code to the following to add Razor Runtime Compilation:
// Add services to the container.
var mvcBuilder = builder.Services.AddRazorPages();
#if DEBUG
mvcBuilder.AddRazorRuntimeCompilation();
#endif
Reproduction
Now set a breakpoint in any view, Index.cshtml would be fine, and run the application.
As soon as the breakpoint is hit, change some Razor code. Or don't, the issues trigger from just having (multiple?) .cshtml files open as well.
Then hit Ctrl+S and F5 to apply your changes and continue running your application, and tada.wav:
Hot Reload can't automatically apply your changes. The app needs to be rebuilt to apply updates.
Alternatively, change some code in the code behind (.cshtml.cs). Now you will get random NullReferenceExceptions or ExecutionEngineExceptions when continuing.
Workaround
Close all .cshtml files before starting a debug session.
Questions
Is it possible to:
Get some confirmation that I'm not the only one that encounters this?
Have "Edit and Continue" without "Hot reload"? The settings for those seem to have been combined, it's either all or nothing.
Make this (editing Razor files and C# code while debugging) work without getting these dreaded errors?
How can I get Microsoft to set the Cancel key (Esc) to the Continue Editing button?
It would appear that not having Razor Runtime Compilation (Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation) installed in the affected project largely mitigates this error (though the runtime still throws the occasional NullReferenceException/ExecutionEngineException while trying to reproduce the issue do my work).
As Hot Reload will also recompile your Razor views, simply uninstall the RuntimeCompilation package and you should get fewer errors.
Edit: this is not entirely true, the error popup still gets shown, albeit less frequently.
Things to try when Hot Reload won't work:
1.) Check the 'Hot Reload' output window and Error List for clues to why hot reload failed. For instance I found an error about having a 'COR_ENABLE_PROFILING' environment variable in the error list after getting the usual dialog. This appeared in the VS2022 17.5 Preview 6.0 and I'm not sure if it was there before.
2.) Make sure COR_ENABLE_PROFILING is disabled in your environment variables.
3.) Search the entire project for RuntimeCompilation (could appear in web.config, launch properties, packages) and remove them.
4.) Disable 'Native Code' debugging in your debugging profile.
5.) Restart your PC and check again

VC6 on Win 10 Debugging when a DLL in another DLL gives User Breakpoint hit

I just installed a Windows 10 machine, since Windows 7 is now dropped... along with the old, classic VC6. Plus the Service pack 6, and the Platform SDK installed. I have been using it this way with no issues on my Windows 7 machine for decades (too long to go into why not upgrade to VS 2010, 2012, 2015, 2017, 2019, yada yada, yada... Subject for a different debate)
I brought up an existing project I was working in before the end of the year. Big exe, several DLLs in it, C++ objects, etc... Was all working fine before Jan 1st.
On my new Windows 10 install, when I tried to launch it in the debugger, it gave an error:
This appears even before main is called. And the executable immediately exists, even before the message box appears, so there is no stack trace to examine. Naturally I looked for any C++ constructors that might be called which could be corrupting things. But there were none. (and never had any issues on my Windows 7 machine anyway)
I narrowed it to the following condition:
The main EXE is linked statically to a LIB/DLL. THAT dll is linked statically to another LIB/DLL
When I remove the underneath DLL dependency, I can run the executable in the debugger.
I've found several projects that are experiencing this.
I have a test project (dsw and dps files) which demonstrates this (at least on my Windows 10 machine) if anyone wants to look at it. It is stripped down to nothing but shells. An EXE that is linked to a DLL, which is linked to another DLL. If I remove the inner DLL dependency in the link stage, the executable with a single DLL work fine.
Also, the EXE will run outside the debugger as well. Both debug and release.
Lastly, when I set the configuration for release, it also runs in the IDE, but has no debug info. However if I enable debug info in the release builds, it again crashes before startup.
So apparently there is yet something in windows 10 that is preventing the debugging container from running. I have also disabled the "Fault Tolerant Heap Shim" but no change.
Has anyone experienced something like this?
Does anyone have any advice?
-Scotty
I've been living without our V6 debugger for a few years now, and after doing yet another search hoping for a solution where I wound up here, I finally found a way and wanted to share it. For projects that give a user breakpoint error and exit immediately on startup, launch them with Build->Execute (ctrl+F5), then do a Build->Start Debug->Attach Process. You won't be able to do anything about the startup, but you can set breakpoints at timers or commands to get in. I guess you could put a long sleep as the first call in your main while debugging to give you a chance to get in and get your breakpoints in place there too.

Visual Studio 2012 fails to compile exe with no code errors

When running a project in Test or Debug configuration in VB.NET using Visual Studio 2012, sometimes it gives the following error as the reason for "Build Failed"
Error 1 Could not copy the file "obj\Debug\MyProgram.exe" because it was not found. MyProgram
There are no issues with the code as it was just compiled seconds before this (sometimes I start the program again just to see how everything gets laid out visually and then go back to the code to make Location adjustments)
What I found is this. If I wait , when I go to test compile again -- it just magically starts working again -- Only to fail again later.
Sometimes, I can get 10-15 good compiles before it wigs out.
About my system configuration:
I do not have any other version of Visual Studio or standalone .NET language installed
The paths are set correctly (else it would never compile in the first place.. not just occassionaly fail)
The program can be a simple program with absolutely no code added (aka... New > WinForms Project > Compile)
The project, language (and all requirements), and project output path are on a local drive that is connected directly to the PC internally (using C:\code* for projects and the standard install location for Visual Studio 2012)
I checked the smart data and scanned my hard drive for any errors ... none ever encountered. The temperature of my system (CPU), and the drive is around 25-30 degrees C.
I am really baffled as to why this happens and at random. I have also tried completely clearing out the bin/ folder, and even Moving the project or repointing where the compiled output path is.
Deleting the .suo file helps sometimes, but not all the time.
I believe this is something that may be able to be tweaked in the UI somehow, however I do not know anything about manually linking and compiling programs.
Lastly -- it does not matter whether I run VS in "Administrator" mode (elevated privileges) or as a user.
Some methods that may help you
Have you tried to reinstall Visual Studio. If that does not work you may need to install some of Windows Updates, the compiler may be missing some essential libraries/references to compile your application.
Check your .Net Target Framework, setting your application to a new framework that you don't have installed can stop the application from compiling yet even stop it from being debugged, having a compiler that is to low, this may come with errors for the compiler but not for the IDE/Visual Studio to notice.
Try cleaning your project solution's output folder by right clicking your solution then try to rebuild your project/solution.
Check your compilation references in your project's properties, check if a reference added is not on your computer
Reinstall/Update .Net Framework, same here some requirements may be missing from your installation
Try installing a newer version of Visual Studio, try Vs2013 - this contains various improvements and fixes, Visual Studio 2015 is fast approaching, a recommendation install VS2015 when the full version gets released it will contain a lot of useful features for future .net programming.
Create an new Administrator account and Run VS with Administrator rights and try compiling then, this fixes some of problems in vs and other microsoft products, it might work here.
Install all of the .Net Frameworks from the lowest to current 4.5, this may help when some of the used references/libraries are not on your local hard drive.
if none of these methods work, i would not know of the problem one last thing you could try is installing Windows to another hard drive and try using that installation of windows and see what happens... Hope this helps.
Best regards!
I faced this kind of problem because of my virus guard
blocked my application(but it is not have any harmful code :) )
exclude your project folder from virus guard
or
simply disable it(not recommended)

Why is my module not in the modules list?

I have a WCF service that I can debug. I put a breakpoint in the code at the point at which I want to debug and get the message
The breakpoint will not currently be hit. The source code is different from the original version.
I have been struggling with this for 3 days now and have tried everything I have found in other posts.
One thing that I notice is that if I go to Debug -> Windows -> Modules the module that I want to debug is not in that list. I think this may have something to do with it. Does anyone know what I should do.
Thanks,
Sachin
EDIT:
I have tried all these things and many more, but for some reason I still have the same problem. Is there any solution to this at all?
Try closing down visual studio after closing any files open in it. Then go into your bin folder for debug and delete all .pdb files. Now reopen visual studio and rebuild your project or do a clean and build ensuring you are in debug mode and not release mode. This issue can arise if your pdb files become locked. If you have a pdb file present for that dll then it should pick up that module for debugging.
If that doesnt work have you restarted your machine? If not try a reboot as sometimes the process can get caught up in Windows, and restarting will release the lock to overwrite the files.
Quick question. Is the module in question an external module or is it part of your current solution that you are debugging? If it is an internal module then the solutions above should definetly work as you will generate a new .pdb file for that assembly.
To state the obvious, this error means that compiled service does not match the source code i.e. source code has changed since service run. Make sure you rebuild your solution.
What I do to debug WCF services is to have 2 instances of Visual Studio. One runs a WCF service hosting app (console) and the other runs a client. Make sure you are running debug version. It should work (and debug) fine as long as the client can successfully connect to your service.
You get
The breakpoint will not currently be hit.
when a module with that breakpoint has not been loaded (yet). Your service will not be loaded until a client connects.
Right click on the project inside the solution explorer and choose to Clean. Build a new version of the project and the breakpoint will work again. If this not work, try to delete everything from the bin and obj folders, and build again your project.

MSBuild called from CruiseControl.NET doesn't pick up build script changes

We're using CruiseControl.NET which invokes an MSBuild script. While debugging the build script, we make small changes constantly and run the build through the CruiseControl.NET web console running on IIS. Everything is just on one machine though since we're just testing.
I've noticed that some changes we make in the MSBuild script aren't picked up. Sometimes they push through, sometimes the server is a few versions out of date. Sometimes restarting IIS services does the trick. Sometimes not even that works.
Is anyone aware of what's happening in the background? Is there some cache we have to clear for web apps? Where could it be?
Edit: To clarify, all my stuff is on a single machine as I'm still in the testing stage. So I don't think source control should be an issue. My ccnet.config simply calls the MSBuild target. Here's a simplified sample:
<project>
<tasks>
<msbuild>
<executable>$(netFrameworkRoot)\MSBuild.exe</executable>
<projectFile>C:\MyProject\ProductBuild.proj</projectFile>
<targets>BuildProject</targets>
</msbuild>
</tasks>
</project>
ProductBuild.proj is a hand-coded MSBuild script that builds a lot of other .NET solutions and packages an installer with a vdproj.
It seems that changes made to my build script do not always take effect when I run a build on CruiseControl. I guess it would be safest to restart the CCNet service, but I was hoping I wouldn't have to interrupt currently running builds.
"run the build through the CruiseControl.NET web console running on IIS" As far as I know the Web Console does not do any building. It sends a message to either ccnet.exe or ccservice.exe, which ever is the on running and listening on port 21234 (unless specified to another port) But to try and get to your problem, Do you have your build project to always get latest? Is your MSBuild file in source control? What source control are you using? Are You changing the MSBuild file in the workspace on the build server? You should post a copy of your project here so we can try to determine the error? I can tell you that as far as CruiseCOntrol is concerned IIS and the web cache has nothing to with the actual compiling. Unless you are talking about the project you are building needs IIS?