VMWare Fusion Shared Folders and Visual Studio Development
So today I had a bit of an adventure that I figured I would document for those of you that may run into this same thing and get just as frustrated as I was for many hours trying to make this work.
I do my work on a MacBook Pro these days. My first setup was to do my .net work in a Vista VM using VMWare Fusion. I created a vmware disk to store my code, installed TortoiseSVN, and worked normally as if I were on a regular windows box. It was a nice little self-contained world.
As my usage of other tools grew, I ran into problems with this setup. Namely:
- Tortoise is aptly named, speedwise. Especially on a VM. But also just on regular windows.
- My files were locked away in my VM unusable by me (in an easy way) natively on the Mac OSX host. This became an issue as I started to work more and more in alternative tools, like MonoDevelop and TextMate.
- My files were locked away in my VM unable to be explicitly backed up by TimeMachine. Less of an issue because they’re in a central source repo, but still an issue.
- I wanted to use Git more and git-svn on windows is…slow. Also cygwin and I are not buddies yet. Plus I have a nice Terminal setup.
- The VMdisk was big, unwieldy, not all that portable, and not all that speedy anyway.
So what I decided to do was set up a VMWare shared folder from my ~/code folder on Mac OSX, exposing it to the guest OS (Vista) as a mapped drive (z: by default). Then I cloned the svn repo with git svn to this folder, checked out a local branch, flipped to my VM, opened the project in Visual Studio, and was prompted with partial trust errors (“Project Location Not Trusted”). At first it seems like ignoring these errors will work, until you go to run some tests, and n number of tools (RhinoMocks, NUnit, SpecUnit, and so on) throw the error that the assembly does not allow partially trusted callers.
Long story short, the solution is to use caspol.exe to set the share to full trust. The documentation on this tool is terse at best, and cobbling together several blog posts (none of which got it right…) I found the command-line magic that made things work.
- Disable UAC (may not be completely necessary, but UAC sucks so do it anyway)
- Open a Visual Studio 2008 Command Prompt as Administrator (right-click and run as administrator) and run the following:
- caspol -m -ag 1.5 -url file://z:/* FullTrust
Breaking that command down a bit, you may have to substitute a couple of params. The -ag 1.5 may be different on your machine. You need to add the share (from mac osx anyway) into the “Internet_Zone” because something to do with the share path starting with a . makes Vista assume it’s in the Internet and not Intranet. To find the group number for your Internet_Zone run the command caspol -m -listgroups and look for the one that says “Zone: Trusted-Internet” (or something similar, I make no claims to Vista operating sanely across all installs). Mine was 1.5.
The second bit you may need to change is the actual share location. Mine mapped to z:/ by default, but you’ll want to check that yourself.
If all goes well you should get a message about “Added union code group with -url membership condition…” and a “success” status. All that out of the way, I reloaded Visual Studio from the share, ran tests, and they failed, but for the right reasons 😉