The easiest way to Install and Boot Windows 8 Developer Preview off a VHD (Virtual Hard Disk)

works-on-my-machine-starburst_3

This post provides the fastest way to get your Windows 8 Developer Preview booting off a VHD. If you’re interested in more details read my previous posts here, here and here.

  1. First of all download Windows 8 Developer Preview here.
  2. Download my script here.
  3. Select Properties on the zip-package and click on the Unblock button.
  4. Extract the zip-package to a folder of your choice.
  5. Mount Windows 8 Developer Preview with your favorite mounting tool, my favorite tool is Virtual Clone Drive you can find it here.
  6. Look for the file “install.wim” in your installation media and remember the path, in my case F:\sources\install.wim.
  7. Open a PowerShell command prompt with the run as Administrator option. You need to run the attached bat-file from a PowerShell console as an Administrator and not from the usual command prompt.
  8. Change directory to the directory where you extracted the zip-package.
  9. Before I show you how to use the CreateBootableVHD.bat file there is 2 important concepts that you need to know:
    • The third parameter in CreateBootableVHD.bat expects you to enter the type of VHD that you want to create. If you choose EXPANDABLE you will need to make sure that you have the specified amount of GB left for the VHD even though the VHD will be small at first.
    • CreateBootableVHD.bat will assign your bootable VHD a drive letter, it’s very important to use a FREE drive letter.
    • When you enter a drive letter make sure you don’t enter a colon after the letter i.e. X and never X:.
  10. Now you’re ready to use the CreateBootableVHD.bat-file like this:
    CreateBootableVHD_v2.bat
    <path where you like to store the VHD, doesn’t work on external drives>
    <size in MB>
    <type FIXED|EXPANDABLE>
    <drive letter assigned to the VHD>
    <path to the wim-file, see number 6 above>

    Ex:
    .\CreateBootableVHD_v2.bat C:\VHD\Win8.vhd 80000 FIXED X F:\sources\install.wim.

Sit back and enjoy as the complete automated process of getting your copy of Windows 8 Developer Preview bootable.

Hope you enjoy it!

Hugo

I don’t want to write comments or run code coverage on autogenerated code

The “warning CS1591: Missing XML comment for publicly visible type or member” issue

You’ve created a WCF service proxy and you’ve XML documentation turned on like the picture shows below.

image

Then you most likely will have a lot of warnings the next time you build your project like so:

image

Don’t despair the solution is close.

Solution

Find the Reference.cs file if you added a Service Reference manually or if you auto generated the Service Reference using the “svcutil.exe” utility open up the generated class.

Add the following line of code in your namespace:

#pragma warning disable 1591 //Disables CS1591 Warning

image

Auto generated code has lousy Code Coverage

Then you’ll be left with the issue that your auto generated code has lousy Code Coverage, if you haven’t written any tests against it that is. The question if you should write tests on auto generated code or not I leave it up to you. I’ll leave at that with the cowardly answer “it depends” Ler The before picture might look like this:

image

Notice how the auto generated namespaces are listed in Code Coverage.

Solution

This is as easily fixed as the XML Warning. In the file where you have the auto generated code use search and replace to add the

[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]

attribute to every class.

image

Finish things off with a Edit->Advanced->Format Document to get a nice formatting and your good to go!

image

Try compiling and watch as your code coverage goes up!

image

Cheers,

Hugo

Creating a bootable VHD the easy way…about Indexes

I’ve seen a lot of people using and downloading my bat-file from my original post here and some of you have even tried some of my more advanced topics here.

There is something worth mentioning with the attached Install-WindowsImage.ps1 that I’ve received feedback from some of you out there. If you would like to install any other Operating System SKU then the default at Index 1 in my bat-file you’ll have to list the images first.

Let’s take a closer look at Install-WindowsImage.ps1:

image

As you can see someone has already been kind enough to provide us with an easy way to list the available images. So if I go ahead and run the example on my own system I get the following:

image

So imagine if I wanted the DataCenter Edition (Full Installation) instead of Standard (Full Installation) I’d have to change the Index in the provided CreateBootableVHD_v2.bat file:

image

Hope that clear any issues with Indexes you might have.

Enjoy!

Hugo