Scott Hanselman

Introducing node.js Tools for Visual Studio

November 21, '13 Comments [93] Posted in nodejs | Open Source | VS2013
Sponsored By
node.js and Express running in VS

Just when you thought it couldn't be crazier in Redmond, today they are introducing node.js Tools for Visual Studio!

NTVS runs inside VS2012 or VS2013. Some node.js enthusiasts had forked PTVS and begun some spikes of node tools for VS. At the same time the PTVS team was also working on node.js integration, so they all joined forces and made NTVS a community project. NTVS was developed by the same team that brought you PTVS with help from friends like Bart Read from Red Gate (he did the npm GUI), and Dmitry Tretyakov from Clickberry for several debugger fixes & features.

NTVS is open source from the start, and has taken contributions from the very start. It supports Editing, Intellisense, Profiling, npm, Debugging both locally and remotely (while running the server on Windows/MacOS/Linux), as well publishing to Azure Web Sites and Cloud Service.

It's actually pretty freaking amazing how they did it, so I encourage you to download it and give it a try because some of the stuff (even given this is an alpha) is very very clever.

Blank Express Application

Node.js Tools for Visual Studio takes advantage of V8 Profiling API's as well Visual Studio's Reporting features to give you a sense of where your program is spending its time.

NOTE: See that File | New Project dialog up there? Visual Studio organizes things by language, so node.js is under JavaScript. But you've also got Python and Django, iOS and Android via C#, TypeScript, VB, F#, all in Visual Studio.

One of the things that's impressed me about the way they integrated node.js into Visual Studio was that they didn't try to recreate or re-do things that already worked well. It's node, it runs node.exe, it uses the V8 debugger, it uses the V8 profiler because that's what people use. Duh. But, for example, NTVS can take the output from the V8 profiler and display it using the Visual Studio Profiler Reporting Tools. No need to reinvent the wheel, just use the right tool for the job.

Hacking on the Ghost blogging engine with node.js for Visual Studio

Let's look at an example.

From within Visual Studio, go File New Project, click JavaScript, then "From Existing Node.js code."

From Existing node.js Code

Point NTVS to your Ghost folder.

Create from Existing Code

Then tell node.js for VS that the startup file is index.js, hit Next, save the project file and Finish.

Create New Project from Existing Code

At this point, you've got Ghost inside VS.

Random: that since I have Web Essentials I also get a nice split-screen markdown editor as well.

From here, just hit F5 to Debug, or Ctrl-F5 to start without Debugging. Also notice the properties of the Project in the lower right corner there showing the node path and port as well as the Startup File. You can change these, of course.

Ghost inside Visual Studio with NTVS

Here's me running Ghost locally. You can see the path to node, the ghost.js file and my browser.

Running Ghost in VS with node for VS

You'll get good intellisense for completions and help for method signatures.

Intellisense example

Debugging

Node.js Tools for Visual Studio includes complete support for debugging node apps. This includes support for Stepping, Breakpoints, "Break on exception", as well as Locals, Watch, Immediate and Call Stack tool windows.

You can manage Exceptions just like any other language service. See in the dialog below node.js exceptions are listed along with other exceptions in managed and unmanaged code.

Managing Exceptions in node.js for Visual Studio

The debugging still happens like it always has, with the node V8 debugger, except Visual Studio connects to the debugger over another socket (remember, you can even debug node.js remotely running on a Linux or Mac like this!) and translates how V8 thinks into how Visual Studio thinks about debugging. The experience is seamless.

See in this screenshot, you can see node.exe is being debugged, I'm running Ghost. You can see my Call Stack, and the Locals in the Watch Window. I can inspect variables, step around and do everything you'd want to do when debugging a Web App.

Debugging Session of Ghost in VS with Node Tools for Visual Studio

npmVisual Studio

The npm experience is pretty cool as well. Node.js for Visual Studio is always watching the file system so are more than welcome to run npm from the command line or from within the node immediate window and Visual Studio will see the changes.

You can also use the npm Package Management dialog and search the repository and install packages graphically. It's up to you.

npm package management within VS

Here's a package installing...

Installing a module

The physical node_modules and how modules are handled is pure node...VS doesn't touch it or care. However, the Solution Explorer in Visual Studio also presents a logical view on top of the physical view.

image

NOTE: I really like this. I think it has potential and I'd even like to see references in .NET treated like this. The physical and the logical, along with a dependency tree showing NuGet packages. It helped me understand the project much better.

There's lots more. There's an REPL interactive window, and you can just publish like any other web project using the same Publish Wizard that ASP.NET projects use. You can publish node.js apps directly to Azure as well, either with Git or with Visual Studio publishing.

You can also remotely debug node instances running on other machines by starting node with the included Remote Debugging Proxy.

image

node.exe RemoteDebug.js -machineport 5860 script.js

As mentioned, you can do remote debugging between Visual Studio and node running on any server OS.

Conclusion

I'm personally pretty happy with the way that Visual Studio is turning (in a short amount of time, seems to me) into quite the competent language and environment factory.

Node.js Tools for Visual Studio is entirely open source under the Apache license and they welcome contributions and bug reports. It's Alpha and it's early but it's awesome. Go get it. Big congrats to all involved!


Sponsor: Thanks to Red Gate for sponsoring the feed this week! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

Disclosure: FYI, Red Gate does advertise on this blog, but it was a total coincidence that a Red Gate employee helped with node.js Tools for VS. I just found that out today. They are very nice people.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Run more apps and show more tiles on your Surface 2 or high-dpi Windows 8.1 Laptop

November 19, '13 Comments [28] Posted in Tools | Win8
Sponsored By
Show more tiles and run more apps on a Microsoft Surface 2

I did a blog post a little while ago about getting real work done on a Surface 2 (ARM & RT) and I've learned a few interesting things since then. The Surface 2 has a great screen. Having 1920x1080p resolution screen on 10.6" screen is really fantastic. In fact, the DPI on the Surface 2 is so nice that working on any other machine (like the 13" 1366x768 laptop I'm writing this on right now) is just unacceptable.

NOTE: This isn't specific to Surface 2. It works on the first Surface Pro, or really, any 1080p or above Windows 8.1 machine!

However, the default DPI settings for both Store Apps and Desktop Apps is set too high, which scales everything and in my opinion this limits you in a few ways. You see fewer tiles on the start screen and can't snap/see more than two Store Apps at a time. If you don't mind smaller on-screen elements, here's a few tricks that will take your high-resolution Surface 2 to the next level. It did mine.

Here's my Start Screen with the default settings as the Surface 2 shipped.

3 rows of Tiles by default

But, if you search for "size" in Settings... (hit the Windows Key+W and type "size")

Size the apps on the screen in Windows 8.1

From this Setting screen, change the Default setting to "Smaller."

Changing Store App sizes

Here's the Start Screen now with the size set to Smaller.

5 rows of tiles

But wait, there's more. Now, go to Settings (Windows Key+C) and click Tiles, then Show More Tiles.

Show more tiles

Now my Start Screen has smaller tiles, but lots more. It's nice to have options.

6 rows of Start Screen Tiles

Here's Mail and News snapped next to each other using the Default DPI setting on the Surface 2.

Mail and News

After changing the setting to Smaller, I can now pull a third application in and the others will get out the way. With 8.1 apps I can resize them to more sizes than 8.0 apps.

 Adding a fourth app and swapping out a third

I prefer the smaller Full Screen/Store DPI setting because I can now read email, check web pages and watch a movie at the same time.

Mail, IE, and Video

I can also bring the Desktop in and run apps over there at the same time I have other Store Apps.

Here I'm running Excel on the Desktop, next to Mail, next to Hulu.

Excel, Mail, and Hulu

After changing Full Screen/Store DPI settings, don't forget you can also changed the DPI for Desktop apps as well. Right click on the Desktop and click Resolution, then "make text and other items larger or smaller." You can play with the settings and find what works. These desktop settings do not change your Store Apps.

Change the size of all items

I hope these tips help you push your own Surface (or any high-DPI laptop) harder.


Sponsor: Thanks to Red Gate for sponsoring the feed this week! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Working Remotely Considered Dystopian

November 18, '13 Comments [50] Posted in Remote Work
Sponsored By

At the time of this writing, I work remotely from Portland, Oregon for Microsoft and have for over 5 years. While I haven't written any books on Remote Work, I think it's fair to say that I am well-versed in successfully working remotely and I am certainly a remote work enthusiast. I have written about the experience extensively on this blog.

Recently DHH, the creator of Ruby on Rails, co-wrote a book about remote work called Remote. Here's the digital "inside cover" from Amazon.

Today, the new paradigm is "move work to the workers, rather than workers to the workplace."

In Remote, inconoclastic (sic) authors Fried and Hansson will convince readers that letting all or part of work teams function remotely is a great idea--and they're going to show precisely how a remote work setup can be accomplished.

And from the Remote book site:

REMOTE, the new book by 37signals, shows both employers and employees how they can work together, remotely, from any desk, in any space, in any place, anytime, anywhere.

MicrosoftiPhoneAppsAwesome. Now we have tools that will move work to the workers like Google Apps, Office 365, and Base Camp. But it seems that workers are taking this too seriously and passing out in bed with their tablets on their faces.

DHH's most recent blog post is called Microsoft's dystopian pitch for remote work and it declares "For shame on Microsoft for cheerleading its [Remote Work's] most dystopian corruption." So, work anywhere, except where you apparently end up needing to work.

Two words that are guaranteed to get folks frothing: "Microsoft" and to a lesser extent, "Dystopian."

As a disclaimer, while I do work at Microsoft, I don't work on Office or know anyone over there. I don't work on any tools or apps that enable you to work remotely unless you count "The Internet." I am a remote worker. If my company disallows remote worker in the future, I will quit.

NOTE: As an related aside, if you want a another REALLY great book about working remotely, I highly recommend "The Year Without Pants" by Scott Berkun, a friendly acquaintance. It's a brilliant account of his time at WordPress.com, a company with only remote workers.

David's primary issue in his post is with this infographic, which is, at best, questionable. But David implies this is a celebration of bad behavior.

Microsoft is launching a new marketing campaign for Office 365 that celebrates working during your kid’s recitals, on vacation, and while enjoying the appetizer at a restaurant.

20% of parents said they have worked at a child's event or activity

Personally, don't really like this campaign either because it strikes at the behaviors that I sometimes do but I know are unhealthy in my heart. We need to ask, is this a behavior we want to enable? That's what's at issue here.

Have we uncovered a secret Microsoft plan to destroy work-life balance? No, but edgy ads like this make us uncomfortable because they catering to the fact that people do work remotely like this. Every time I go out to dinner I see couples sitting together in silence while they type away on their pocket supercomputers. No, it's not healthy nor should it be how remote work gets done.

But don't forget how the Microsoft ad opens.

Survey finds that more than half of U.S. office workers would be willing to work more hours — and one in five would even take a pay cut — to have more flexibility to get work done.

Again, you like that you can work remotely, but you don't like where people end up working remotely? Thing is, nearly every app and suite that enables to you work remotely has used the soccer game thing to the point that it's approaching trope status. Here's Google, with the same pitch.

Access your work from any device with a web browser – your computer, phone or tablet – and stay productive even when you’re away from the office. Need to attend a meeting from your kid’s soccer game? Edit a spreadsheet while at the airport waiting for a flight? Respond to an email from a hotel business center computer?

Need to attend a meeting from your kid’s soccer game?

Yes, it's bad (sub-optimal, whatever you want to call it) to work at your kids' soccer game. But it's sometimes necessary. Sometimes work-life balance means that work leaks into life and vice versa.

I think it's great if you can literally turn off all access to work at 5pm on Friday and turn it back on at 9am on Monday. Bravo and good for you. For me, it doesn't always work that neatly. I am happy that when needed I can chat someone at work, send a file, share a screen, or forward an email quickly without going into the office.

It's a odd ad campaign, I agree. It's inverted in its priorities. But, I like having the ability to put out a fire while I'm at a soccer game. It's clearly better than missing the soccer game completely. Having tools to get stuff done remotely means I am empowered. If I choose to use that power for evil, that's hardly Microsoft's fault (or iCloud or Google or Dropbox, etc) or the Internet for existing.

It's good that tools like this exist. But I agree with David that it's probably not a good idea to advertise or endorse admittedly unhealthy behavior.

DHH clearly doesn't like Microsoft, and that's fine. But rather than railing against the company that makes tools (and admittedly poor ads) about enabling remote work, why not direct that frustration at the companies with cultures that have workers up at 2am? Or even better, at the managers who demand this level of access?

For the record, when I'm not travelling I drop of my kids at school every day, pick them up at 3, go on fields trips (where I'm usually the only non-homemaker), and tuck them in every night after reading books.

Full Disclosure: I use Office 365 at work, Google Apps for Business at Home, access them all from my iPhone 5S and Surface 2 and store stuff in DropBox. I'm non-denominational.

I'll end with my unwavering agreement on what David said here:

It’s about spending the hours of work more productively, and then having more time free from its tentacles.

Sound off in the comments. How bright is the line between things work and things personal? Do you shut off and shut down, or are you working a little everywhere? How does this affect how you, and those around you feel about you and your work?


Sponsor: Thanks to Red Gate for sponsoring the feed this week! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Portable Class Libraries just got REALLY useful with new licensing changes

November 14, '13 Comments [16] Posted in ASP.NET | Open Source
Sponsored By
Flickr Photo by thienzieyung used under Creative Commons
 

It takes a little while to turn a large ship. I love the .NET community and I'm happy to have been a part of it from the beginning. I'm also happy that I'm helping (in a small way) turn the ship from the engine room along with a lot of like-minded individuals.

Sometimes what seems like a "can't you just" request requires days and weeks of legal this-and-that and meetings and "alignment" (that's a thing business people LOVE to say). But if you're patient and keep pushing, change happens.

You have have noticed on the .NET Blog this week that Portable Class Libraries are now enabled for Xamarin. You perhaps remember this post on Portable Class Libraries that I wrote, with this screenshot:

image

Today on 2013 with Xamarin installed, I see this after File | New Project.

image

Of course, there's still wasted space, but I hope you can see the change. ;) The more interesting,  perhaps, change is the legal licensing changes to make sure you're allowed to use useful Portable Libraries on other platforms, like Xamarin.

In my original post there were negative (and these discussions continued on Twitter and UserVoice) comments like:

Hi Scott, unfortunately that wasted space you refer to can't be used until MS changes the licensing on many of their Nuget components (e.g. HttpClient) as these stipulate that they have to be used on Windows systems... making them far from portable!
Are you aware of this, and do you know whether this situation will change in the near future?

Yes, it just changed. We've been lifting these as fast as we could, starting with ASP.NET Katana in July, getting PCLs everywhere, and finally changing licenses on ALL these libraries this week.

The lifting of this restriction also applies to some non-portable libraries like, ALL the Microsoft .NET NuGet Libraries, the Entity Framework and all of the Microsoft AspNet packages.

Go forth and be happy. Even  better, you can use these portable libraries as  dependences to new portable libraries that you create and share.

Ships may turn slowly, but they do turn, and ultimately, in significant ways.


Sponsor: Thanks to Red Gate for sponsoring the feed this week! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Why do my Font Awesome icons show up as blank squares?

November 4, '13 Comments [28] Posted in Open Source
Sponsored By

So you've decide to use Font Awesome for some great scalable icons. You download them, maybe you use the Bootstrap CDN.

  • You're not an idiot, but you only get black squares.
  • You look at the F12 Developer Tools and you can see the fonts are getting downloaded.
  • You're super advanced, so you check that mime/types are correct on your web server and confirm them in the HTTP headers.
  • You've burned a half hour just pressing CTRL-F5 and clearing browser caches.
  • You're about to smack someone.
  • You're trying different browsers, checking the wire, reading the docs, googling with bing for crying out loud.

Sigh.

image

Then you realize that you need to have class="fa" as well as whatever the icon's class is.

So, not just

<i class="fa-pencil" title="Edit"></i>

But in fact, you need

<i class="fa fa-pencil" title="Edit"></i> 

Then...it works.

image

I hereby declare this the Foux du Fa Fa rule of Font Awesome and blog it so I don't forget.


Sponsor: Big thanks to Telerik Icenium for sponsoring the feed this week! Build and publish iOS & Android apps with Visual Studio using only HTML5 & JavaScript! Telerik Icenium now includes Visual Studio integration. Start a 30 day trial with support now!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.