HowTo: Building the vSphere Web Services SDK 4.1 for .NET

One of my gripes about the vSphere Web Services SDK (formerly VI SDK) is that the process to generate .NET web services stub files has always been a bit of a mixed bag. This is especially true if you like to operate on the cutting edge of technology and use modern IDEs. Microsoft released Visual Studio 2010 in April (of 2010) and VMware released their latest version of the vSphere Web Services SDK (4.1) two months later, and the latter offers no support for the former. You might argue that two months isn’t enough time to support a new product the size and scope of Visual Studio, but I call shenanigans for three reasons:

  1. Development versions of Visual Studio 2010 have been available in some form or fashion since last fall.
  2. Which is besides the point, because building the web services stub files and the sample projects does not require Visual Studio!
  3. I put together a Visual Studio-less compatible version of the vSphere Web Services SDK 4.1 build process in about 30 minutes.

Here is how to build the vSphere Web Services SDK 4.1 without Visual Studio 2010 and for .NET 3.5 and 4.0.

The vSphere Web Services SDK 4.1 package includes a DotNet directory that contains batch files for building the web services stub files using Visual Studio 2005 or 2008. Using the 2008 files, Build2008.cmd and genvimstubs2008.cmd as starting points, I created Build2010.cmd and genvimstubs2010.cmd (ripping out all references to Visual Studio). Download the files and place them in the same directory with the older versions.

From a command prompt (it doesn’t haven’t to be a Visual Studio command prompt, because Visual Studio is not a requirement for building the web services stubs — although you will need the Windows SDK) you can now run the command following command to generate the vSphere 4.1 web services stub files:

Build2010.cmd

The above command will generate assemblies dependent upon the .NET 4.0 runtime. If you want to generate assemblies using the .NET 2.0 runtime with the .NET 3.5 framework and its tools (and I recommend that you do), simply execute the same file with a single parameter of 1 like so:

Build2010.cmd 1

This will cause the stubs and examples to be built using the .NET 3.5 compiler against the .NET 2.0 runtime (the same runtime that the vSphere4 client uses — that means you can use these assemblies from within vSphere4 plug-ins, if you depend on the .NET 4.0 runtime you cannot). You can view the output of this command here.

You may be asking why do the outputted assemblies still have the “2008” suffix? This is because all of the sample projects reference VimService2008 or Vim25Service2008 and if I updated the file names to 2010 then I’d have to update all of the “.csproj” files to reference the new names. It was simpler to leave the file names as is. If you really want to change them, you can edit two place-holder variables I created at the top of the Build2010.cmd file.

Oh, and if you’re wondering how the samples are built without Visual Studio. Simple — I employ the msbuild program — which ships with the .NET framework and does not depend on Visual Studio. The other tools the Build20xx.cmd files depend on, wsdl.exe, sgen.exe, all ship with either the .NET framework or Windows SDK. No more Visual Studio needed!

Hope this helps!

9 thoughts on “HowTo: Building the vSphere Web Services SDK 4.1 for .NET

  1. Thanks for putting this together.

    I have downloaded the .bat files that you put together, put these into the sdk folder but gettign the following error:

    C:\Users\hyltonj\Downloads\VMWare-sdk>Build2010.cmd 1
    USEDOTNET35=”1″
    WSDLFILE=””..\..\wsdl””
    \RSA was unexpected at this time.
    C:\Users\hyltonj\Downloads\VMWare-sdk>Build2010.cmd
    USEDOTNET35=”0″
    WSDLFILE=””..\..\wsdl””
    \RSA was unexpected at this time.

    I have opened back up the Solution in VS2010 but still not able to get the samples working. When looking at the Using I still can not find the VimApi that the solution is looking for. I have tried to add a reference to this, however I can not find anything with the SDK folder that I can add a reference too.

    Any help here would be greatly appreciated!

    thanks!

  2. For P. Davey and anyone else who is getting an error running the Build2010.cmd script with a message like, “\Microsoft was unexpected at this time”, this is because you are running this on a 64-bit platform and the “Program files (x86)” portion of the path is causing problems with the compound parenthesis in the IF-ELSE statement. See http://www.blinnov.com/2010/06/04/microsoft-was-unexpected-at-this-time/en/ for a detailed explanation.

    Unfortunately the solution provided in the blog above (remove the quotes from the path) does not work. Because of the limitation of having to use parenthesis for compound IF-ELSE blocks, the only way I have been able to get this to work is to remove the IF-ELSE statement and just use the SET PATH statement relevant to the way you wish to build the project (1st statement for 3.5, 2nd statement for 4.0)

  3. Brad, 10x for your efforts!

    I believe I did it :-)

    Anyway – I’ve got two poblems with the CMD files you’ve posted:
    1) The 64-Bit OS issue – thanks to your latest comments I fixed it
    2) The SDK is installed in a folder which has ‘spaces’ in the name: “C:\Local Data\Visual Studio 2010\Projects\vSphereSDK”….etc.

    As a result of 2) the CMD file was not able to complete successfully. Moving the SDK to “D:\Development\vSphereSDK\” solved the problem ;-)

Leave a reply to baroniparson Cancel reply