Scott Hanselman

Visual C++ for Linux and Raspberry Pi Development

April 6, '16 Comments [13] Posted in Open Source | VS2015
Sponsored By

It's bananas over at Microsoft. Last week they announced you can run Bash on Ubuntu on Windows 10, and now I'm seeing I missed an announcement of an extension to Visual Studio that enables Visual C++ for Linux Development.

With this extension you can author C++ code for Linux servers, desktops and devices. You can manage your connections to these machines from within VS. VS will automatically copy and remote build your sources and can launch your application with the debugger. Their project system supports targeting specific architectures, including ARM which means Raspberry Pi, folks.

ASIDE: I also noticed there's a C/C++ extension for Visual Studio Code also. I need to add that to my list of stuff to check out, it looks pretty compelling as well.

Once Visual C++ for Linux Development is installed, you go and File New Project like this. Cool to see Linux in that list along with a Raspberry Pi project.

File New | Linux App

You can pick x86, x64, and ARM, and you can see Remote GDB Debugger is an option.

Remote GDB Debugger

Here I'm running Ubuntu in a VM and connecting to it over SSH from Visual Studio. I needed to set up a few things first on the Ubuntu machine

sudo apt-get install openssh-server g++ gdb gdbserver

Once that was setup, connecting to the remote Linux machine was pretty straightforward as VS is using SSH.

Debugging C++ apps remotely talking to a Linux VM

Pretty cool.

NOTE: Today this cool extension has nothing to do with the Bash on Ubuntu on Windows announcement or that subsystem.  The obvious next question is "can I use this without a VM and talk to gdb on the local Linux subsystem?" From what I can tell, no, but I'm still trying to get SSH and GDB working locally. It's theoretically possible but I'm not sure if it's also insane. Both teams are talking, but again, this feature isn't related to the other.

This extension feels a little beta to me but it does a good job providing the framework for talking to Linux from VS. The team looks to be very serious and even has a cool demo where they code and debug a Linux desktop app.

If you're looking for a another full featured solution for Linux and Embedded Systems development with Visual Studio, be sure to download and check out VisualGDB, it's amazing.


Sponsor: Quality instrumentation is critical for modern applications. Seq helps .NET teams make sense of complex, asynchronous, and distributed apps on-premises or in the cloud. Learn more about structured logging and try Seq free for 30 days at https://getseq.net.

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 ORCS Web

Developers can run Bash Shell and user-mode Ubuntu Linux binaries on Windows 10

March 30, '16 Comments [115] Posted in Open Source | Win10
Sponsored By

UPDATE: I've recorded a 30 min video with developers from the project as well as Dustin from Ubuntu about HOW this works if you want more technical details.

As a web developer who uses Windows 10, sometimes I'll end up browsing the web and stumble on some cool new open source command-line utility and see something like this:

A single lonely $

In that past, that $ prompt meant "not for me" as a Windows user.

I'd look for prompts like

C:\>

or

PS C:\>

Of course, I didn't always find the prompts that worked like I did. But today at BUILD in the Day One keynote Kevin Gallo announced that you can now run "Bash on Ubuntu on Windows." This is a new developer feature included in a Windows 10 "Anniversary" update (coming soon). It lets you run native user-mode Linux shells and command-line tools unchanged, on Windows.

After turning on Developer Mode in Windows Settings and adding the Feature, run you bash and are prompted to get Ubuntu on Windows from Canonical via the Windows Store, like this:

Installing Ubuntu on Windows

This isn't Bash or Ubuntu running in a VM. This is a real native Bash Linux binary running on Windows itself. It's fast and lightweight and it's the real binaries. This is an genuine Ubuntu image on top of Windows with all the Linux tools I use like awk, sed, grep, vi, etc. It's fast and it's lightweight. The binaries are downloaded by you - using apt-get - just as on Linux, because it is Linux. You can apt-get and download other tools like Ruby, Redis, emacs, and on and on. This is brilliant for developers that use a diverse set of tools like me.

This runs on 64-bit Windows and doesn't use virtual machines. Where does bash on Windows fit in to your life as a developer?

If you want to run Bash on Windows, you've historically had a few choices.

  • Cygwin - GNU command line utilities compiled for Win32 with great native Windows integration. But it's not Linux.
  • HyperV and Ubuntu - Run an entire Linux VM (dedicating x gigs of RAM, and x gigs of disk) and then remote into it (RDP, VNC, ssh)
    • Docker is also an option to run a Linux container, under a HyperV VM

Running bash on Windows hits in the sweet spot. It behaves like Linux because it executes real Linux binaries. Just hit the Windows Key and type bash.

After you're setup, run apt-get update and get a few developer packages. I wanted Redis and Emacs. I did an apt-get install emacs23 to get emacs. Note this is the actual emacs retrieved from Ubuntu's feed.

Running emacs on Windows

Of course, I have no idea how to CLOSE emacs, so I'll close the window. ;)

Note that this isn't about Linux Servers or Server workloads. This is a developer-focused release that removes a major barrier for developers who want or need to use Linux tools as part of their workflow. Here I got Redis via apt-get and now I can run it in standalone mode.

Running Redis Standalone on Windows

I'm using bash to run Redis while writing ASP.NET apps in Visual Studio that use the Redis cache. I can then later deploy to Azure using the Azure Redis Cache, so it's a very natural workflow for me.

Look how happy my Start Menu is now!

A happy start menu witih Ubuntu

Keep an eye out at http://blogs.msdn.microsoft.com/commandline for technical details in the coming weeks. There's also some great updates to the underlying console with better support for control codes, ANSI, VT100, and lots more. This is an early developer experience and the team will be collection feedback and comments. You'll find Ubuntu on Windows available to developers as a feature in a build Windows 10 coming soon. Expect some things to not work early on, but have fun exploring and seeing how bash on Ubuntu on Windows fits into your developer workflow!


Sponsor:  BUILD - it’s what being a developer is all about so do it the best you can. That’s why Stackify built Prefix. No .NET profiler is easier or more powerful. You’re 2 clicks and $0 away, so build on! prefix.io

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 ORCS Web

Docker for Windows Beta announced

March 26, '16 Comments [22] Posted in VS2015
Sponsored By

Docker Desktop AppI'm continuing to learn about Docker and how it works in a developer's workflow (and Devops, and Production, etc as you move downstream). This week Docker released a beta of their new Docker for Mac and Docker for Windows. They've included OS native apps that run in the background (the "tray") that make Docker easier to use and set up. Previously I needed to disable Hyper-V and use VirtualBox, but this new Docker app automates Hyper-V automatically which more easily fits into my workflow, especially if I'm using other Hyper-V features, like the free Visual Studio Android Emulator.

I signed up at http://beta.docker.com. Once installed, when you run the Docker app with Hyper-V enabled Docker automatically creates the Linux "mobylinux" VM you need in Hyper-V, sets it up and starts it up.

"Moby" the Docker VM running in Hyper-V

After Docker for Windows (Beta) is installed, you just run PowerShell or CMD and type "docker" and it's already set up with the right PATH and Environment Variables and just works. It gets setup on your local machine as http://docker but the networking goes through Hyper -V, as it should.

The best part is that Docker for Windows supports "volume mounting" which means the container can see your code on your local device (they have a "wormhole" between the container and the host) which means you can do a "edit and refresh" type scenarios for development. In fact, Docker Tools for Visual Studio uses this feature - there's more details on this "Edit and Refresh "support in Visual Studio here.

The Docker Tools for Visual Studio can be downloaded at http://aka.ms/dockertoolsforvs. It adds a lot of nice integration like this:

Docker in VS

This makes the combination of Docker for Windows + Docker Tools for Visual Studio pretty sweet. As far as the VS Tools for Docker go, support for Windows is coming soon, but for now, here's what Version 0.10 of these tools support with a Linux container:

  • Docker assets for Debug and Release configurations are added to the project
  • A PowerShell script added to the project to coordinate the build and compose of containers, enabling you to extend them while keeping the Visual Studio designer experiences
  • F5 in Debug config, launches the PowerShell script to build and run your docker-compose.debug.yml file, with Volume Mapping configured
  • F5 in Release config launches the PowerShell script to build and run your docker-compose.release.yml file, with an image you can verify and push to your docker registry for deployment to other environment

You can read more about how Docker on Windows works at Steve Lasker's Blog and also watch his video about Visual Studio's support for Docker in his video on Ch9 and again, sign up for Docker Beta at http://beta.docker.com.


Sponsor: Thanks to Seq for sponsoring the feed this week! Need to make sense of complex or distributed apps? Structured logging helps your team cut through that complexity and resolve issues faster. Learn more about structured logging with Serilog and Seq at https://getseq.net.

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 ORCS Web

How to set up a Raspberry Pi 3 from scratch (with video)!

March 23, '16 Comments [14] Posted in Hardware | Open Source
Sponsored By

My messy electronics workspaceMarchIsForMakers continues! It's my month-long collaboration with Saron from CodeNewbie. We've had some amazing guests on our respective podcasts and some great technical content. Please do check it out at http://marchisformakers.com and subscribe to my podcast Hanselminutes as well as the CodeNewbie podcast.

Here's a few of the things we've made for you lately:

Just last week I received my Raspberry Pi 3 in the mail. I called Saron and we decided not only to do an unboxing video, but an "unboxing, setup, AND make it do something" video.

Could we setup a Raspberry Pi 3 from scratch and get it to blink an LED in less than an hour?

Every STEM house should have a Raspberry Pi or six! We've got 4? Or 5? They end up living inside robots, or taped to the garage door, or running SCUMMVM Game Emulators, or powering DIY GameBoys.

If you have a Raspberry Pi 3, awesome. If not, this should work with an original Pi or a Pi 3. You'll want to make sure you have a few parts ready to save you time and trips to the store! I recommend a complete Raspberry Pi Kit when you're just getting started as it guarantees you'll be up and running in minutes. They include the mini SD Card (acts as a hard drive), a power supply, a case, etc. All you need to provide is a USB Keyboard and Mouse. I ended up getting a cheap Mini USB wired keyboardand cheap USB wired mouse for simplicity.

I like to use the new NOOBS setup direct from Raspberry Pi: https://www.raspberrypi.org/help/noobs-setup/. You can get SD cards with NOOBS preinstalled are available from many of our distributors and independent retailers, such as Pimoroni, Adafruit and Pi Hut if you like, but I had a blank card laying around.

I downloaded SD Formatter 4.0 for either Windows or Mac and prepped/formatted my card. Then I downloaded NOOBS and unzipped it directly into the root of my now-empty SD Card.

You plug the SD card into the Raspberry Pi and pick Raspbian as your Operating System (although there are other choices this is easiest for beginners) and wait a bit. The default login is "pi" and the password is "raspberry."

In this video we not only set it up, but we also got VNC working using RealVNC for Raspberry Pi, then Blinked an LED using Python. It was a blast, and was a little touch and go for a moment near the end as we had to pull out the multimeter to debug!

I hope you enjoy it. Also, be sure to explore the #MarchIsForMakers hashtag on Twitter to see lots of other fun stuff folks are doing during our month-long celebration.

What have you made this month?


Sponsor: Thanks to Seq for sponsoring the feed this week! Need to make sense of complex or distributed apps? Structured logging helps your team cut through that complexity and resolve issues faster. Learn more about structured logging with Serilog and Seq at https://getseq.net.

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 ORCS Web

Building Visual Studio Code on a Raspberry Pi 3

March 15, '16 Comments [32] Posted in Hardware | Open Source
Sponsored By

Visual Studio Code running on a Raspberry Pi 3 - Michonne Approves

I picked up a Raspberry Pi 3 recently for MarchIsForMakers. The Raspberry Pi 3 is a great starter computer for makers not just because it is faster than the Pi and Pi 2, but because it has Wifi built in! This makes setup and messing around a lot easier.

Here's some great tutorials for getting started with the Raspberry Pi, Node, and Visual Studio Code.

I also recommend folks setup a VNC Server for their Raspberry Pi so you can TightVNC (meaning, remote in and control) into the Pi from your PC. You can also setup your Raspberry Pi to share the clipboard so you can copy from Windows and Paste into the VNC window when you are remoted into your Pi.

But why not build Visual Studio Code and get it running natively on the Pi? Marc Gravell did it first on Twitter, but I wanted to figure out how he did it and if it was still possible (he did it before some significant refactoring) and also to see if VS Code was faster (or even usable) on a Rasberry Pi 3.

Compiling Visual Studio Code on a Raspberry Pi 3

From the VS Code GitHub, you need Node, npm, and Python. The Pi has Python but it has an old node, so needed a newer node that ran on ARM processors.

get http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

There are some NPM native modules like node-native-keymap that didn't work when I built the first time, so you'll need some supporting libraries first:

sudo apt-get install libx11-dev

Then, from my Raspberry Pi, I did this to build my own instance of VS Code.

git clone https://github.com/microsoft/vscode
cd vscode
./scripts/npm.sh install --arch=armhf

This took the Raspberry Pi 3 about 20 minutes so be patient.

Then, run your instance with ./scripts/code.sh from that same folder.

Note: Electron and Chromium underneath it use some very specific features of X Servers like "xrandr" for dynamic resizing and you may have trouble getting Visual Studio Code to run under a remote VNC session. Consider using RealVNC or TigerVNC for your Raspberry Pi, rather than the older TightVNC. RealVNC is a commercial product but they'll give you a free license for your Raspberry Pi.

Once you've updated to a newer VNC you can run VS Code

image

Check out MarchIsForMakers all month long as we partner with CodeNewbies and play and learn with maker hardware! Last week we unboxed my Raspberry Pi 3, set it up, and got it to blink an LED!

What have YOU done with your Raspberry Pi? Sound off in the comments.


Sponsor: Big thanks to Redgate for sponsoring the feed this week! Feeling the pain of managing & deploying database changes by hand? New Redgate ReadyRoll creates numerically ordered SQL migration scripts to take your schema from one version to the next. Try it free!

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 ORCS Web

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