Skip to content

Vagrant file and provisioning for Rust Windows development

Notifications You must be signed in to change notification settings

nbigaouette/windows_vagrant_rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Windows Virtual Machine

Provisioning a Windows 10 virtual machine allow compiling and debugging the project natively.

Microsoft provides virtual machine images that will expire after 90 days of the their first use. To prevent issues, provisioning is done to automate the setup of the VM, allowing deletion without loss of productivity. It also assures that everyone uses the same reproducible environment ("environment as code").

After a VM is provisioned, it will stay valid for 90 days. One has to destroy that VM before that and re-provision a new one.

The current working directory will be shared inside the VM as C:\vagrant. In the VM, simply change to that directory and compile as needed.

NOTE: To prevent the target directory (where cargo puts its compilation artifacts) to be recompiling code from macOS/Linux and Windows, the VM has the variable CARGO_TARGET_DIR environment variable set to C:\cargo_target. This means the compilation artifacts will stay inside the VM and will disappear on VM destruction (required at least every 90 days). Also, this should speed compilation since the shared drive uses the network interface between the guest VM and the host.

Vagrant

Vagrant allows provisioning a virtual machine, similarly as Docker allows provisioning a container.

Download and install vagrant, either from its website, homebrew or your Linux package manager.

You will also need a Virtual Machine hypervisor. The Vagrant configuration file specifies VirtualBox, which is free (and open-source). Other hypervisors where not tried or tested.

Download

  • Download the virtual machine archive
  • Unzip the archive.
    • MSEdge - Win10.box's sha256sum: 8896d48cb1c63c53d3e6484bba0a7a539818cf855dab7aeacabc243f004d7f63
  • Rename the file to MSEdgeWin10.box (no spaces)

Add the box to Vagrant's database:

> vagrant box add \
    --checksum 8896d48cb1c63c53d3e6484bba0a7a539818cf855dab7aeacabc243f004d7f63 \
    --checksum-type sha256 \
    windows10_x64_1809 \
    MSEdgeWin10.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'windows10' (v0) for provider:
    box: Unpacking necessary files from: file:///path/to/MSEdgeWin10.box
==> box: Successfully added box 'windows10' (v0) for 'virtualbox'!

Managing the Virtual Machine

VM Creation and Provisioning

Create and boot the virtual machine:

> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'windows10_x64_1809'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: Rust Dev - Windows 10 x64 (1809)
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 5985 (guest) => 55985 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:55985
    default: WinRM username: IEUser
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
==> default: Machine booted and ready!
    [...]

The full provisioning can take up to 20 minutes to do. Please be patient!

Delete VM

Note that this is required to be run at least every 90 days since the VM license expires after that.

vagrant destroy

Connection

OpenSSH is installed in the VM. Simply connect to it:

ssh IEUser@localhost -p 2222

Password is Passw0rd! as defined here: https://az792536.vo.msecnd.net/vms/release_notes_license_terms_8_1_15.pdf

About

Vagrant file and provisioning for Rust Windows development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages