You will need to place your custom rule assemblies in the installation folders of each policy you have installed (that's just how StyleCop works) along with the StyleCop installation folder. If you do not place your rules in the StyleCop folder, you will
not have access to them if you right click and run StyleCop manually.
To work on the policy, it is best to create a virtual image of a Microsoft Team Foundation Server to use as a test server. Oracle VM VirtualBox (www.virtualbox.org) is free, and can forward ports from the host machine to the guest. That is a requirement if
you want to use a virtual machine to test integration with TFS. Once you have your virtual server created hosting TFS, you can forward the port from your host machine to the guest using the VBoxManage command line tool included with VirtualBox.
VBoxManage.exe setextradata "<Your Virtual Machine Name Here>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/tfs/GuestPort" 8080
VBoxManage.exe setextradata "<Your Virtual Machine Name Here>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/tfs/HostPort" 55000
VBoxManage.exe setextradata "<Your Virtual Machine Name Here>" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/tfs/Protocol" TCP
That will forward the data from port 55000 to port 8080 on the guest machine over the TCP protocol. You will need to replace the guest port if you change the default port number Team Foundation Server uses. You can change the HostPort as well if you would like
to use a different port number on the host machine.
Next, ensure the SourceAnalysisPolicy project is set as your default startup project and start the project for debugging. After the initial experimental hive has finished loading, you will need to close it and open regedit to add a key connecting the development
policy to the experimental hive.
- Open regedit.exe from the run command window.
- Navigate to: HKCU\Software\Microsoft\VisualStudio\10.0Exp\TeamFoundation\SourceControl
- If it does not exist, create a key named "Checkin Policies"
- Create a new string value in the key called "Winnster.CheckInPolicies.SourceAnalysis" and set the data to the fully qualified compiled path of the bin\Debug folder. It should look something similar to "C:\SourceAnalysisPolicy\bin\Debug\Winnster.CheckInPolicies.SourceAnalysis.dll"
After completing the registry key, you can register your lab TFS server with the experimental hive of Visual Studio just like any other TFS server. Just make sure you change the port number to 55000 or whichever port you chose earlier.