Okay, so it’s a long title. And hey, this is a long post (I seem to be doing that recently) but I was struggling with VMs, IE7, and SharePoint and figured I would put this together for those that want to build their own SharePoint development environment in a stand-alone virtual machine. While it’s still basically install a few pieces of software, there’s a lot of configuring going on, extra tools you can (should) use, and a few gotchas when it comes to Virtual Machines and things like Visual Studio solutions.
Note that this is my preferred setup. It has tools that I use and configurations I prefer. This isn’t the only way to fly and I’m sure others out there have other ways of doing this (for example developing on a Windows XP box rather than directly on a server, using differencing disks, local files, small lizards, logging chains, etc.) but this works for me and I’m comfortable with it. Most tools and VS addins are optional and totally up to the reader. Feel free to tweak these instructions as you see fit, add/remove/suggest components, or throw it out altogether.
This is part of my bag of tricks I’m sharing with you. Please use it for good, not evil.
This assumes that you’ll be using a virtual server type of software (Virtual PC, Virtual Server, or VMWare). Makes no difference but I prefer Virtual PC for now as I can drag and drop files from my desktop into it. Virtual PC and Virtual Server images are compatible so you can build in VPC and use it in Virtual Server if you want. I generally give the VM 1–2GB of RAM as its going to be running everything (Windows Server, SQL, SharePoint, Visual Studio, etc.) so it’ll need it (1GB when I run on my laptop which has a max of 2GB, and 2GB to the VM when I run on my desktop which has a max of 4GB).
I generally don’t keep source code in my VM (or it’s very temporary, say for demos) so I keep it generally on an external drive. This drive is shared to the VM as the Z:. Also keep your VHD files (Virtual Hard disk, or whatever VMWare uses) on an external drive. Mucho better performanco.
Also this a workgroup install rather than a domain controller. Some people like having a DC running with SharePoint but I like to keep it separate. You can also spin up a domain controller VM and connect the machine to the domain through the local network later.
Okay, here’s the rundown of what gets installed. Some things can be shifted around in order of preference, but obviously you can’t install SharePoint before you install SQL Server. Again, feel free to move things around as you see fit.
No detailed instructions for installing most of this (but feel free to ask for clarification on anything, as some of it might not make much sense). Just follow the wizards entering whatever information is needed and you can generally accept the defaults. Really, it’s not that complicated. Also I make things easy for development like creating a single user for everything and just giving them admin rights to the box. In a real setup you would have domain accounts and only grant them the rights they need in SQL Server. I just find having as few things possible make it easier for development (and we’ll worry about configuration later in the test/production environment).
- Install Windows Server 2003 Standard Edition. Any edition will do, but this one works fine.
- Install Windows Server 2003 Service Pack 1
- Create local spadmin account on the machine. Add to the Local Administrators group. This will be used for all portal functions.
- Create local spuser account on the machine. You can use this as a reader or contributor on your sites for testing (and feel free to create more, but I find two is enough)
Setup IIS. Just the basic options are needed here.
- Remove event tracker shutdown dialog. What a PITA this thing is for development.
- I prefer to browse to http://machinename rather than http://localhost. Add machinename to trusted sites in IE for this to work. This will eliminate the NT challenge/response dialog when you browse to the site, and all urls will be better formed.
- Edit the command prompt to add QuickEdit. Just handy when copying/pasting things like wp part packs in the command window.
- Install hMailServer. This is a free (open source) SMTP/POP3 server that I use instead of Exchange. Lightweight and free. Alternately you can install Exchange if you really want to.
- Add a catch all account to the mail server – email@example.com. This will be used for any mail to/from the Portal or WSS sites.
- Add user account – firstname.lastname@example.org. This is attached to the user account for the portal (or you can use admin for everything)
- Install SQL 2000. Standard OOTB install, configure it to run in mixed mode. I use SQL instead of the built in MSDE so I do testing with full text searches.
- Install SQL 2000 SP4.
- Install SharePoint Portal Server 2003 without the database engine. We’ll connect it to SQL during setup phase.
- Configure and create the initial portal. Name it whatever you want like “Development Portal”, “My Little Pony”, “Big Man Hands”, whatever.
- Use the spadmin account name you created above for all operations.
- Use localhost for the mail server.
- Give spadmin email address of email@example.com.
- Add machinename\spuser (firstname.lastname@example.org) as reader to the portal.
- Install WSS SP2. Have to install this before we install SPS SP2.
- Install SPS SP2.
- Add shortcut to 60 HIVE directory on desktop or QuickLaunch. I just find it a pain to navigate down the ugly tree anytime I need to hit the directory in Explorer so having a folder that goes directly there is handy.
Add STSADM dir to path in command prompt. I find this very handy so I can open up a command prompt and just start typing STSADM rather than the full path. Optionally you can install STSADMWin or whatever. I’m just a command prompt kinda guy
- Change WSS_Minimal in web.config to Full. This is required to set debugging=true and makes life easier.
- Set debug=true in compilation section of web.config for debugging Web Parts
Visual Studio Setup
- Install and Configure Visual Studio 2003. I just select the default which includes C# and VB.NET but you do whatever works for you.
- Copy keyboard shortcuts (so ReSharper can install, if you’re installing it)\
- Install Web Part Templates for Visual Studio .NET. These are the templates for creating new Web Part Library projects.
- Install ReSharper. Set the persistence to use the local drive (this is for performance of local files vs. remote). I prefer ReSharper but some like CodeRush, Refactor Pro!, and other tools.
- Install GhostDoc. I use this for creating stub documents for APIs and Web Parts that I’ll be sharing.
- Install TestDriven.NET. Killer app for TDD and running unit tests. Also includes NCover now.
- Copy InstallAssemblies (from the Web Part Toolkit) to server and add to QuickLaunch. You just need the EXE and I like having it on the QuickLaunch taskbar as I can just click on it and install a web part quickly.
- Install SharePoint Explorer. Best tool for looking at what you have.
- Install SmartPart (if you’re planning to do development via User Controls)
- Install Office 2003
- Install FrontPage 2003
Install Other Tools
- TopStyle. I use this for editing CSS files but feel free to use Visual Studio (blech) or your own CSS editor (Notepad anyone?)
- XmlSpy. This comes with a cost, but it’s worth it for Xml editing. There are some less expensive packages and then there’s always… Notepad!
- IE Dev Toolbar. Very handy for debugging pages and poking around in SharePoint sites.
- Notepad++/Notepad2. I prefer these over the standard Notepad.
- Paint.Net if you plan on making your own icons or graphics. Free and written in .NET!
- SysInternals BGInfo. I have this in my startup for the server as it shows me what the server name is, IP, and other info that is handy when you’re flipping around between machines.
- Plus any other tools you like. Scott Hanselman’s list here is a great resource.
- Create a new web part using the template (Hello World or something)
- Install using InstallAssemblies. This will add it to the bin dir and create the SafeControl entries in web.config so the web part will work correctly.
- Add the web part to a page somewhere.
- Run Web Part project in Visual Studio with debugging to make sure debugging works
- Create an alert, open up Outlook Express and configure it to use your local mail server (if you installed it). You should receive an alert.
Security and Source Code
When working in a VM you generally do NOT want your source code to be in the VM (just in case it turfs and you can’t recover it) so I keep all my source on an external drive (rather than say the host drive as I move from place to place). I also only have it set to use Local networking meaning it can’t see out and I can’t see in (which is why I prefer Virtual PC so I can drag/drop files to the VM). This allows me to have a domain controller on the local network if I need it.
With Virtual PC you can share this drive as a network drive letter inside the VM (my external drive is always Z:. In order to open files and not get the dreaded “the project location is not fully trusted” you need to fix security policy if you want to open files from a network drive. Google "the project location is not fully trusted" and you’ll get a ton of answers. Problem is that none of these work for a drive that is mapped into a VM. A drive shared shows up in the Intranet Zone. Bizzare huh? Means you have to trust the entire internet zone. Not a good thing. Can’t use z:\\, have to use file:// but there is no file:// for a mapped drive (because there is no server name).
James Kovacs says to use ZoneStripper but I really don’t want to do this with each project so the technique below works well:
- Open the ".NET Framework Configuration" utility
- Expand "Runtime Security Policy->Machine->Code Groups"
- Right click "All Code", and then select the "New..." item
- Type a name in the "Name" textbox (like “VS Projects on Z:“ or something), and then click the "Next" button
- Set the condition type to "URL" and type the following string to the "URL:" textbox: “file://Z:/*”
- Click the "Next" button and assign the "FullTrust" permission set to this Code Group.
This will trust all code on Z: and not display the dialog. You can also use file://servername/* but since we’re working with a drive letter here, we don’t have a server name.
I also run regular scheduled backups of my external drive to whatever host it’s connected with using SyncToy so I generally always have 3 copies around (1 on laptop, 1 on desktop, 1 on drive) and do make weekly DVD backups of the source and CVS trees.
Tips and the Afterlife
- After your environment is setup, all the tools are running, and you’re happy with what you have created SAVE IT! Snapshot that puppy so you can come back to it. Some people might prefer to use undo disks but again, I find these sometimes have issues so I just copy the whole dang VHD file as an archive in case the worst happens.
- Setup a Development Area in the Portal. Two things I do as a final step in getting things up and running on the portal. If I installed SPS then I create an area called Development. This is just a collection of sub-areas for various projects, spike web parts, whatever. It leaves the rest of the default portal setup intact as I don’t need to build a taxonomy that represents a production site or anything. If I need something like that (for example to demo what a sample navigation structure might look like) I’ll just create a new Virtual Server in IIS and create a portal off it. I keep the main portal on port 80 for general development.
- Another thing I do is copy the STS definition and create a new STSDEV site def from this. Not much is changed in the definitions but I do go in and add a top and bottom zone to the default.aspx page. This lets me a) screw around with any list definitions without touching the default STS one and b) have some extra zones to mess with in case I want them. I also setup 10 pages in the default module which are copied at creation time. These are placeholder pages (copied from default.aspx) which I can use instead of web part pages and are ghosted so I don’t worry about them showing up in something like Ghost Hunter. Finally I create a new site called Sandbox using this config and add it to my Development section in SPS as a listing to quickly get to it. For most web parts, I develop them so they work in both a SPS area and a WSS site (unless it has SPS specific stuff).
Okay, now go start using your portal for development. It’s complete, self-sufficient, and fun for the whole family.