Category Archives: Visual Studio

QuickBytes: Visual Studio 2013 and JavaScript Debugging

Yesterday I found out something new about Visual Studio. Documentation indicates that it has been with us since VS 2012 (maybe earlier) but I encountered it yesterday.

I have a MVC4 project created in VS2010 and some CSHTML files have accrued some JavaScript crud in form of inline <script>…</script>. I usually refactor them out whenever I can but yesterday I was doing something else and wasn’t in a position to refactor the code at that point. So I tried to put in a breakpoint inside one of these script chunks and I couldn’t. So far, I’ve put breakpoints in the runtime page that comes up in Visual Studio’s Solution Explorer and they were are hit when executing in the browser, but yesterday I couldn’t even set a breakpoint.

After a little bit of ducking around I found that you could add the following line in the JavaScript to force the debugger where you want to start debugging and then continue with F10/F11 as usual

debugger;

I was initially indignant at Visual Studio that it ‘made’ me do this by default instead of allowing me to set the breakpoint. Looks a step backward, but then I realized that it was likely some setting in my Dev Setup is not right. I haven’t had a chance to investigate what’s not right, and I used the above hack to resolve my current issues. If you know of a way that kicks VS2013 into enabling breakpoints in inline JS code, do let me know.

Inline JS code is BAD and shouldn’t be used, period. But at times when you are prototyping you tend to take liberties, also not everyone in the team has 15 years of experience writing code, so cruft sometimes comes in. If VS is forcing my hand by making me write clean JavaScript code by default, that’s good, but I also want to know the ‘evil’ way to workaround Winking smile, Cheers!

Tagged , ,

QuickBytes: Visual Studio 2013 refuses to load some projects from a VS2010 solution

Last night I opened an ASP.NET MVC project in Visual Studio 2013 that was originally created in Visual Studio 2010 and found that 4 of the six projects in the solution were not loading. This solution was working in VS 2012 earlier so I was wondering what went wrong!

After goofing around I found the Output Window (the Window menu has been split up and moved around in VS2013 – It’s at Debug->Windows->Output; Who moved my cheese!!!). On selecting Solution from the ‘Show output from’ dropdown, I saw one such error for each project that was not loaded:

C:\Users\SKM\Documents\My Projects\[redacted].csproj : error  : The imported project “C:\Users\SKM\Documents\My Projects\[redacted]\.nuget\nuget.targets” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  C:\Users\SKM\Documents\My Projects\[redacted].csproj

That’s when it struck me the code dump was created using the Visual Studio Extension SolZip, which excludes the .nuget folder and thus Nuget Package Restore was failing. So the fix was easy:

1. Right click on Solution
2. Enable Nuget Package Restore
3. Reload each project or save->close->and re-open solution
4. Restore Packages from Nuget and you are done!

This is more of a reminder for myself!

Tagged , , ,

Rant on Visual Studio Maintenance Experience

Warning: This is a Rant. I am waiting for my new VM to finishing patching itself. So spending time ranting here.

———– BEGIN RANT ———-

Last week, the Visual Studio team released the 2011 Beta. Unfortunately a day before that I had figured out that my VS Setup was hosed enough to not allow MVC4 beta to be installed. Now I don’t usually install Beta in my dev machine but since MVC4 Beta came with a go live license and it promised to live side-by-side MVC3 I decided to go for it.

I started downloaded the complete installer and initiated the install and quickly it said that it did not find Visual Studio Installed hence couldn’t continue. I was like huh WAT!?!

Naturally I turned to the venting machine also known as Twitter.

Jon Galloway from the ASP.NET team kindly responded suggesting a possible conflict. He also suggested I post it on the official forum for better response. After a few feeble attempts at uninstalling/reinstalling I posted on the Forum @ http://forums.asp.net/p/1772359/4850404.aspx/1?p=True&t=634657393972716075

I was surprised to find there was a special Visual Studio Uninstaller, but alas it was of no use.

Microsoft used to have a registry cleaner deep buried inside their TechNet site. It was like a bazooka to eliminate all registry entries for an application listed in Add Remove programs. Obviously you could  hurt yourself a lot with it (I had hurt myself once, but it had atleast ended up in me reinstalling VS only not setting up a new VM). But Microsoft got the wind of it and they have replaced it with a safer version of the software http://support.microsoft.com/kb/2438651 . Running this tool repeatedly resulted in some improvement as in the Visual Studio Installer started going to the point where it would ask which components you want to install. But hopes got dashed promptly after when it crashed saying it couldn’t continue and that none of the components were installed.

After doing it for the fifth time on the third night I gave up and started building a new VM.

———END RANT———-

——– BEGIN CHALLENGE ——

Here is my challenge to the Visual Studio team. You have been known to eat your own dogfood right? Visual Studio is built on .NET. Build an XCopy Installer that does not use the Registry, period!

All your UX changes are fine. But if I have to setup a new VM every-time a minor revision is released, you are NOT optimizing for developer happiness or presenting a good developer experience.

Beta might be too late a stage to take this challenge up. But hey, here it is!

——– END CHALLENGE ——–

Tagged , , ,
%d bloggers like this: