You can remotely debug a SharePoint farm solution in your local Visual Studio without having SharePoint locally installed.
1. You have a ready on premise SharePoint Server2. You have Visual Studio 2013 installed on your local machine. (ex. Windows 7/Windows 10)3. You have created identical debug user accounts on both the local host and server machines and add to Local Administrator group on both machines (not sure if admin group is necessary, but better to add it in Administrators group).
Execution in Windows Registry:
1. Go to your SharePoint Server and export 15.0 hive from regedit.exe (Run As Administrator)-[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0]
2. Enter a meaningful name for this exporting file and save.
3. Copy the exported ‘.reg’ file to your local development machine.
4. On your local development machine, open your regedit.exe (Run as Administrator) and navigate to same path [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0]
5. Select File > Import > Select your copied .reg file and click Open and you are done.
Steps to perform in Visual Studio 2013:
1. Open Visual Studio 2013 as Administrator.
2. Create a new project (I created a SharePoint 2013 – Visual Web Part)
3. In the below wizard, do not change any values, do not click Validate. Simply click Finish.
4. Copy the required SharePoint DLL to your local development machine and add them to References in your VS solution. (I added only Microsoft.SharePoint.dll. You may need more SharePoint DLL depending on SharePoint classes used in your code.)
1. When you are done coding, build the solution and copy pdb file to the SharePoint server. (You will find this pdb file in bin folder)
2. Right click solution and choose Publish. This will create wsp file.
3. Copy this wsp file to the SharePoint server and deploy the solution:
Use Add-SPSolution and Install-SPSolution.
4. Activate the web part from Site Settings and add it to any SharePoint page.
5. Navigate to one of the below location to find your solution folder:
6. Copy the pdb file to your solution folder. Now your solution’s DLL and PDB file are in same folder.
7. On the SharePoint server navigate to [C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Remote Debugger\x64] and run msvsmon.exe as Administrator. You will have below window now running.
8. In the Debugging Monitor window choose > Tools > Permissions and check if the account by which you are running your Visual Studio on your local machine has Debug permission, if not grant it.
9. Open Windows PowerShell on SharePoint Server and run this command:
C:\Windows\System32\inetsrv\appcmd list wp
This command will list all WP process currently running. Note down the WP process ID that you want to attach in Visual Studio. (Example shown below. My Web Part is deployed to 11724, therefore I will choose only this WP ID while attaching to the process in Visual Studio).
Back to Visual Studio 2013:
1. Tools > Attach to Process > Enter “YourDomainName\YourDebugAccount@YourSharePointServerName” in Qualifier field and click Find button.
2. Choose details returned and press Select.
3. Select “Show processes from all users” and press Refresh button.
4. Among the listed w3wp process, choose the one that you had noted earlier in above step 8.
5. Refresh your SharePoint page and happy remote debugging. (Assuming that your breakpoint is under Page_Load event.)