Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create virtual machines as part of a build process using MSBuild and MS Virtual Server and/or Hyper-V Server Virtualization?

What I would like to do is create a clean virtual machine image as the output of a build of an application.

So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a location on the virtual machine hard disk, and IIS configured correctly, the VM would start up and run.

I know there are MSBuild tasks to script all the administrative actions in IIS, but how do you script all the actions with Virtual machines? Specifically, creating a new virtual machine from a template, naming it uniquely, starting it, configuring it, etc...

Specifically I was wondering if anyone has successfully implemented any VM scripting as part of a build process.

Update: I assume with Hyper-V, there is a different set of libraries/APIs to script virtual machines, anyone played around with this? And anyone with real practical experience of doing something like this?

like image 407
Adam Avatar asked Aug 14 '08 21:08

Adam


People also ask

How do I create a virtual machine in Hyper-V?

Create a virtual machine by using Hyper-V ManagerOpen Hyper-V Manager. From the Action pane, click New, and then click Virtual Machine. From the New Virtual Machine Wizard, click Next. Make the appropriate choices for your virtual machine on each of the pages.


2 Answers

Checkout Powershell Management library for Hyper-V on CodePlex. Some features:

Finding a VM
Connecting to a VM
Discovering and manipulating Machine states
Backing up, exporting and snapshotting VMs
Adding and removing VMs, configuring motherboard settings.
Manipulating Disk controllers, drives and disk images
Manipluating Network Interface Cards
Working with VHD files

like image 184
vitule Avatar answered Oct 02 '22 04:10

vitule


You can actually script a fair number of tasks in MS Virtual Server:

http://www.microsoft.com/technet/scriptcenter/scripts/vs/default.mspx?mfr=true

http://msdn.microsoft.com/en-us/library/aa368876(VS.85).aspx

Also Virtual PC guy has got a ton of stuff on his blog about scripting Virtual Server/PC and now Hyper-V here:

http://blogs.msdn.com/virtual_pc_guy/default.aspx

VMware has similar capabilities:

http://www.vmware.com/support/developer/scripting-API/

like image 42
Kev Avatar answered Oct 02 '22 02:10

Kev