Loading projects in VMs with source on Host

I've been playing around lately with various VM solutions on my Mac - my goal was to get an environment where I can run Vista and VS2008 in the VM, but have the source code on my host drive. That way, I can browse the source without needing to boot a VM, plus it gets included in my backups (both TimeMachine & Crashplan).

I've tried 3 different VM providers - VMWare, Parallels & VirtualBox, with mixed results. All three offer a Shared Folders feature, that automatically shares directories from the host as if they were network shares. However, for both VMWare & VirtualBox there was a problem. My company uses TFS for pretty much everything, and the Team Explorer client within Visual Studio didn't like these shares for some reason. Trying to do pretty much anything resulted in an "Unexpected error code 1" message.

They did work using a regular network share (i.e., sharing my host directory over SMB, and then connecting to the from the guest), but I didn't much like that approach; for one, I imagine there's some additional processing overhead, and secondly since my host is a laptop it's IP address is regularly changing as I move around, causing issues with my share on the Windows side. I'm sure I could have got something working, but it sounded like a PITA.

Parallels, however, worked like a treat. Just setup the shared folder, and TFS is quite happy with it. The next problem comes when you try to load a project into Visual Studio. It responds with

The project location is not trusted:

z:\project

Running the application may result in security exceptions when it attempts to perform actions which require full trust.

Now, if you google you'll find a ton of hits about this, and about how to solve it. One of the best is here - in particular, this chap actually explains what everything means. Here's the command that you need:

caspol.exe -m -ag 1.2 -url file://\\.psf/Projects/* FullTrust

Note that it doesn't matter if you are loading the code directly from the share (\\.psf\Projects in this case) or from a drive letter mapped to the share; both equate to the same thing internally.

The key thing in this command is the "-ag 1.2" - that's saying that the share is to be as a child of group 1.2. What's group 1.2? Well, if you run

caspol -lg

you'll get an output something like this:

1. All code: Nothing
1.1. Zone - MyComputer: FullTrust
  1.1.1. StrongName - 0024000...: FullTrust
  1.1.2. StrongName - 00000000000000000400000000000000: FullTrust
1.2. Zone - Intranet: LocalIntranet
  1.2.1. All code: Same site Web
  1.2.2. All code: Same directory FileIO - 'Read, PathDiscovery'
1.3. Zone - Internet: Internet
  1.3.1. All code: Same site Web
1.4. Zone - Untrusted: Nothing
1.5. Zone - Trusted: Internet
  1.5.1. All code: Same site Web

Here, you are seeing the list of groups that are currently setup. Note that the top level groups (1.1, 1.2 etc) correspond to the Internet Explorer zone settings. When the access policy is being processed, the first step taken is to determine the zone that the code is coming from (MyComputer, Intranet etc). Once this is done, only the policies within that zone are then examined to determine the level of trust that the code has. So adding your new FullTrust setting to group 1.2 only makes any difference if the \\.psf\project share is considered to be part of the Intranet zone. If it's not in that zone, then your new rule will just be ignored.

How do you know what zone your code is in? Load up Explorer, and then browse to the share. The zone will be shown in the status bar at the bottom:


explorer.jpg

Given this setup (which appears to be the default for a VM within Parallels), I need to do:

caspol.exe -m -ag 1.5 -url file://\\.psf/Projects/* FullTrust

to add my new rule to the Trusted zone. Anything else will have no effect. The vast majority of the posts out there on using caspol for network shares don't mention this, so hopefully this will help someone out!

Comments

# re: Loading projects in VMs with source on Host
Gravatar Very good write up! .. I linked to your posted from here forum.parallels.com/showthread.php . We found under Windows XP and VS2008 that the "." in the share name doen't allow you to load projects.
Left by Jason H on 3/6/2009 7:27 PM
# 
Gravatar Loading projects in Visual Studio using the Shared Profile feature in Parallels
Left by florianb.net on 4/30/2009 11:43 PM
# re: Loading projects in VMs with source on Host
Gravatar Where should I put the command? thanks a lot for the help
Left by Veronica on 9/2/2009 3:35 PM
# re: Loading projects in VMs with source on Host
Gravatar Hi Veronica,

Simply run the command in an elevated command prompt. If you use the command prompt within the Visual Studio Tools folder in the start menu, then the paths will be correct for resolving caspol.

Hope that helps!
Left by sstrong on 9/4/2009 6:53 PM
# re: Loading projects in VMs with source on Host
Gravatar It is not working for me :( Using VMware 3.0, Windows 7, Visual Studio 2008

Got somebody else the same problem? Please help!

Left by Petr Kaleta on 10/27/2009 6:42 PM
#  Loading projects in Visual Studio using the Shared Profile feature in Parallels
Gravatar Loading projects in Visual Studio using the Shared Profile feature in Parallels
Left by Pingback/TrackBack on 10/31/2009 2:50 AM
# re: Loading projects in VMs with source on Host
Gravatar Petr,

It's working for me in VMWare, but the command is slightly different. Try:

caspol -m -ag 1.3 -url "file://\\vmware-host\shared folders/*" FullTrust

So the difference is that in VMWare, you need to add the permissions to group 1.3 (Internet zone), and the path is different.

Hope that helps!
Left by sstrong on 11/4/2009 10:01 AM
# re: Loading projects in VMs with source on Host
Gravatar Fantastic - thank-you for pointing out how to figure out the correct 'zone' (by using Windows Explorer). Made my day :)
Left by Mr. Bungle on 2/12/2010 11:32 PM

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 5 and 5 and type the answer here:

Preview Your Comment.