Configure Linux Mint/Ubuntu Screen Resolution Under Hyper-V

As a .NET developer running Windows 10 I had just about given up running Linux in a virtual machine on my development machines.  Once you install Visual Studio 2012/2013/2015 with all the bells and whistles (specifically the tooling to support Windows Phone development) you end up with Hyper-V installed and configured on your system to support the Windows Phone simulators.  The obvious thing to do then is to create your VM in Hyper-V, but that results in a virtual machine running in a window @1024×768 or @ 1152×864 which is a little annoying on a 1920×1080 display.  (This is definitely workable, but it is annoying).  After poking for a while inside Linux trying to get the resolution set to 1920×1080 I decided that surely I needed virtual display drivers much like I have used in the past with VMware.   I began scouring the web for the Hyper-V equivalent of the VMware Tools.   Unfortunately I wasn’t having any luck finding what I was looking for.

If you think you might try VMware or Virtual Box along side your Hyper-V installation, think again.  Running either of these platforms along side Hyper-V is difficult due to compatibility issues.  In particular they clash around the virtual network adapters.  I was able to get this scenario to work, but it required creating scripts to disable Hyper-V and then rebooting the machine to switch between the two visualization platforms.

After doing some research I found that it was possible to get the virtual machine to boot up with your desired resolution with a little modification to your grub file,  here’s how to make it happen.

  • Install the latest version of your distro of choice (Ubuntu or Linux Mint anyway)
    • I used Mint 17.2 (Rafael) with the Cinnamon desktop for my virtual machine
  • Open up a terminal window
  • Navigate to your /etc/default directory
    • cd /etc/default
  • Open your grub file for editing as an administrator
    • sudo gedit grub
  • Find the line GRUB_CMDLINE_LINUX_DEFAULT and change it to :
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920x1080"
  • Update your grub file
    • sudo update-grub

Now just reboot your Linux virtual machine and you’re good to go.

Resources

http://nramkumar.org/tech/blog/2013/05/04/ubuntu-under-hyper-v-how-to-overcome-screen-resolution-issue/

Configuring a Custom NuGet Feed in Visual Studio

Configuring a custom NuGet feed in Visual Studio couldn’t really be any simpler.  For example, I have a custom feed hosted on MyGet.org that hosts the CI nugget builds for my open source projects.   To configure Visual Studio to use it just go to the Tools|Options in the menu and then expand the NuGet Package Manager node on the left side of the dialog and select Package Sources.

NuGet Feed Settings

Next click the + button in top right to add a new entry, select the new item in the list of available package sources, change the name and the source and click update.

That’s it, now your all set to pull in packages from your new feed.

Testing Legacy Versions of Internet Explorer

The emulation tools in Internet Explorer’s F12 Developer tools are a godsend when you have to support older, legacy versions of IE in your solution, but sometimes you’ll run into issues where even the emulation mode isn’t close enough to the real thing.  That’s exactly what happened to me recently.  I was developing a new feature in an ASP.NET MVC application using Angular.js on the client and the page wasn’t updating after calling the server to refresh, but only in IE 9.  Weird, it worked just fine on my machine in IE 11 emulating IE 9, but I had just watched the QA engineer do the exact same thing in IE 9 and it had definitely not worked.

Luckily Microsoft has been kind enough to provide virtual machine images that can be downloaded for just this purpose on the modern.ie web site (http://dev.modern.ie/tools/vms/).  To use these virtual machines you will need to have Hyper-V, VirtualBox,  Virtual-PC, or VMWare installed.  In my case I chose to use VirtualBox, but I also have seen VMWare work with the same steps.

Steps To Configure Your Machine

In order to get your machine configured so you can run IE9 (or another version) in a virtual machine running against your local machine follow these steps.

  1. Download and install the latest version of VirtualBox from Oracle @ https://www.virtualbox.org/wiki/Downloads
  2. Download the appropriate Virtual Machine Image from modern.ie @ http://dev.modern.ie/tools/vms/
  3. Virtual Machine: [Choose the version of IE and Platform you wish to test]
  4. Platform: Select VirtualBox
  5. Click Download .zip
  6. Extract the contents of the zip and save it someplace safe.
  7. The zip should contain a file named “IE9 – Win7.ova” or something similar.
  8. Launch VirtualBox
  9. Select File Import Appliance
  10. Browse to the file you saved in step 3 (IE9 – Win7.ova) and click next
  11. Optional: I adjusted the memory from 512MB to 2GB (I would recommend this if you have the memory to spare on your host PC.)
  12. Click Import and wait…
  13. The import process took about 40 minutes on my machine…
  14. From an Elevated Command Prompt (Run as Administrator) Execute: netsh http add urlacl url=http://myhostname:2000/ user=everyone
    1. Substitute whatever your machine name is for the host name (myhostname)
    2. Substitute the port number you are using when running your application in IIS Express.
  15. Edit your IIS Express Application Configuration file (at My Documents > IIS Express > config > applicationhost.config)
  16. Find the binding for the application you would like to debug
  17. <binding protocol=”http” bindingInformation=”*:2000:localhost” />
  18. Copy this line and paste it as a new line directly underneath the existing line in the XML
  19. Change “localhost” to the name of your computer.
  20. <binding protocol=”http” bindingInformation=”*:2000:MyComputerName” />
  21. Start the application running in Visual Studio.
  22. Some of the documentation I found online suggests that you may need to run Visual Studio with elevated permissions (Run as Administrator), but that has not been my experience. I suspect I may already have whatever permission is needed on my account, your mileage may vary.
  23. Launch your virtual machine
  24. Browse to http://MyComputerName:2000/

Note: I expected to have to make a Windows Firewall rule to allow the traffic but I did not have to in order to get it working on my machine. If you have issues, that is the first place I would look. I would probably just turn off windows firewall all together and test. If that works, turn it back on and create a rule.

Note: I ran into an issue today where I needed to log in and I didn’t know/remember the password for the IEUser account on the virtual machine.  You can find that information in the Virtual Machine Instructions document.

Continuous Integration/Deployment Using GitHub, AppVeyor & Microsoft Azure Websites

There are plenty of tools available these days that a developer or development team can use to set up continuous integration/deployment.  AppVeyor is one such tool that I first heard about last spring (May 2014) when reading a post by Scott Hanselman entitled “AppVeyor – A good continuous integration system is a joy to behold“.   I thought it sounded pretty interesting and so I gave it a try.  It was so easy and simple to set up that I had builds up and running in 15 minutes and I had it deploying to my Azure Websites account in under 30 minutes!

Getting up and running is straight forward assuming you already have GitHub and Azure accounts. These aren’t hard to set up either, but for the purpose of this demo I’ll be assuming you already have one of each.  (Everyone does right?)  To demonstrate how to get things set up I have created a little demo site and checked it into GitHub.  It’s a very simple project which is basically the default ASP.NET MVC template.  I’ve stripped out a few of the endpoints, changed the text on the one remaining page and added in some unit tests that can be run as part of our build.  I’ll probably add onto this site later for other demos or just for fun, but for now this will be adequate for us to take a look at the build and deployment process using GitHub, AppVeyor and Microsoft Azure Websites.

Getting Set Up On AppVeyor

Now that we have an ASP.NET project on GitHub we can get started setting up AppVeyor to build our project.  The first step is to set up our account.  At the time of this writing there is a big green button labeled “SIGN UP FOR FREE” right on the home page.  Click that button, select a plan (I’m choosing the “Free – for open-source projects” option), and choose log in with GitHub.  You can also select BitBucket or Visual Studio Online if you would like to use one of those services instead.  I have not tried them, but I would assume they work exactly the same.

AppVeyor Sign Up Screen

Once you log into GitHub you will be presented with an authorization screen from GitHub.com asking you to confirm that you would like to authorize AppVeyor to access your account.  Click “Authorize application” to authorize AppVeyor and continue with set up.

GitHub Authorization ScreenNext you’ll see the project screen which will be empty at this time except for large item that says “+ NEW PROJECT”.  Click this link to add a new project to your account.   This will take you to a page to select the source control repository you would like to pull from.  The page will default to GitHub and after a few seconds your GitHub Repositories will appear.  If you now hover over the repository you would like to add a button will appear to the right so that you can add the repository.  Click the add button.

Select Repository GitHub - Add

Your First Build

At this point you should have things configured enough to build your repository.  Simply click the “New Build” button on the right to start a build!

Build QueuedNotice that the build is now queued up, the site has pulled in the commit message, time and author and it has automatically incremented our version number to version 1.0.1.  We can manipulate these version numbers in the settings if we wish as well allowing us to make it version 2.0, 2.1, etc.  The server will simply keep incrementing the build number.

Once the build actually begins we will be able to view the console output.

Build Console Output

And once it completes we will get a success or failure message.

Build Success

Notice the green “Build Success” message.  We now have everything configured and any time we commit on the master branch a build will be triggered.  We can customize the branches that build etc. in the settings which I will dig into in a later post.

Also note here that the server has automatically detected and run our unit tests!  Had any of our tests failed the server would have failed the build as well.

Setting Up Azure Websites

The first thing we will need to do in order to deploy our site to Azure is create the site in Azure.  If you already have done this or your site is already live on Azure go ahead and skip ahead to the next step – Configuring Deployment.

Start off by going to the Microsoft Azure Portal (https://manage.windowsazure.com/) and once you are logged in click the “WEBSITES” link on the left side bar and then click the New button in the lower left corner.

Portal Websites

A panel will appear at the bottom of the screen.  Select “COMPUTE”, “WEBSITE” & “CUSTOM CREATE”.

New Compute Website Custom Create

Enter a URL for your website and click the check mark button.

Custom Create Dialog

After a little churning your site will be created.  While we are here there is a little piece of information we will need later, so let’s get that now.  Click on your new site in the websites list to view the details.

Website details

Now click the “Download the publish profile” link on the right side of the page and save it off to your local disc for later use.

Configuring Deployment

To configure your deployment go back to AppVeyor, select your project, click settings and then when the settings page loads go to the build section (third item down the left side).  You’ll need to be sure the option “Package Web Application for Web Deploy” is checked and then save your changes.

Build Settings - Package for MS Deploy

Next go down to the Deployment section (three more items down).  First click “Add Deployment” to add your first deployment and get started configuring it.  You’ll need to select the “Web Deploy” deployment provider.  This is where we need the info in the publish settings file we saved earlier.  Specifically we need the settings publishUrl,  msdeploysite, username, and userPWD.  These values go into the fields in the deployment section as follows:

Server = https: //[publishUrl]/msdeploy.axd?site=[msdeploySite]
Website Name = [msdeploySite]
Username = [username]
Password = [userPWD]

You will also want to turn off NTLM.

Deployment Settings

Click the “Save” button and we should be ready to give it a try.  To start a new build click “LATEST BUILD” and then “NEW BUILD”.  Assuming we’ve done everything correctly a build of your project will queue up and if it is successful it should deploy to you site on Microsoft Azure.

The site is at: http://dependencyinjector.azurewebsites.net/
The GitHub Repository is at: https://github.com/dependencyinjector/dependencyinjector
The AppVeyor Build Information is at: https://ci.appveyor.com/project/lahouse/dependencyinjector

Resources

Documentation:
http://www.appveyor.com/docs/deployment/web-deploy#provider-settings

Scott Hanselman’s Blog Post: http://www.hanselman.com/blog/AppVeyorAGoodContinuousIntegrationSystemIsAJoyToBehold.aspx