在没有sharepoint环境的中开发sharepoint程序
经常sharepoint开发同行说,只有在安装sharepoint的环境中才能开发sharepoint应用吗?其实不然,这篇文章就是讲解如何解决这个问题的。
One of my biggest pet peeves when doing SharePoint development is the "requirement" that you work on a machine with SharePoint installed. On some levels this makes sense -- you will actually need a SharePoint environment to test whatever code you write. On the other hand, a development server that runs SharePoint and all of the pieces it needs (e.g. SQL server) requires a lot of resources. Usually you end up with a sluggish, unresponsive machine to develop on which affects a SharePoint developer's productivity.
So what? Just code on another machine and deploy to a SharePoint environment, right? If you've ever tried that with Visual Studio 2010, you've probably seen this error trying to create a project... "A SharePoint server is not installed on this computer. A SharePoint server must be installed to work with SharePoint projects."
Fortunately there is a simple trick to get around the error and start building SharePoint projects off of the server. It involves modifying the registry -- be careful!
1) Log on to a working SharePoint server (2010 in this case) and fire up Registry Editor.
2) Locate this key: HKLM/Software/Microsoft/Shared Tools/Web Server Extensions.
3) Right-click and select Export.
4) Save the file (it will have a .reg extension) and move it over to the machine without SharePoint installed.
5) Double-click the .reg file to import the settings in the registry.
So far, so good. Now if you actually want to *build* your code, you'll have to take a couple more steps.
6) Zip up the relevant DLLs from your sharepoint server and copy to the development machine. Be careful that this doesn't violate your license.
7) Using GACUtil, install the DLLs into the GAC.
7.5) (if working with an existing project) Add the necessary references to your project (Microsoft.SharePoint, perhaps more).
8) Re-open Visual Studio, and try again to create an "Empty SharePoint Project".
Voila! It should work without a hitch.
There are a few limitations when developing in this setup. Not all of the SharePoint-related functionality will work -- for example, adding a Content Type to your project will result in an error. This is because it uses Visual Studio's "SharePoint Connections" which cannot be accessed from off-server.
Another thing that won't work is the right-click > Deploy menu option. You'll have to write your own script to deploy remotely or manually copy the WSP and install it.
One of my biggest pet peeves when doing SharePoint development is the "requirement" that you work on a machine with SharePoint installed. On some levels this makes sense -- you will actually need a SharePoint environment to test whatever code you write. On the other hand, a development server that runs SharePoint and all of the pieces it needs (e.g. SQL server) requires a lot of resources. Usually you end up with a sluggish, unresponsive machine to develop on which affects a SharePoint developer's productivity.
So what? Just code on another machine and deploy to a SharePoint environment, right? If you've ever tried that with Visual Studio 2010, you've probably seen this error trying to create a project... "A SharePoint server is not installed on this computer. A SharePoint server must be installed to work with SharePoint projects."
Fortunately there is a simple trick to get around the error and start building SharePoint projects off of the server. It involves modifying the registry -- be careful!
1) Log on to a working SharePoint server (2010 in this case) and fire up Registry Editor.
2) Locate this key: HKLM/Software/Microsoft/Shared Tools/Web Server Extensions.
3) Right-click and select Export.
4) Save the file (it will have a .reg extension) and move it over to the machine without SharePoint installed.
5) Double-click the .reg file to import the settings in the registry.
So far, so good. Now if you actually want to *build* your code, you'll have to take a couple more steps.
6) Zip up the relevant DLLs from your sharepoint server and copy to the development machine. Be careful that this doesn't violate your license.
7) Using GACUtil, install the DLLs into the GAC.
7.5) (if working with an existing project) Add the necessary references to your project (Microsoft.SharePoint, perhaps more).
8) Re-open Visual Studio, and try again to create an "Empty SharePoint Project".
Voila! It should work without a hitch.
There are a few limitations when developing in this setup. Not all of the SharePoint-related functionality will work -- for example, adding a Content Type to your project will result in an error. This is because it uses Visual Studio's "SharePoint Connections" which cannot be accessed from off-server.
Another thing that won't work is the right-click > Deploy menu option. You'll have to write your own script to deploy remotely or manually copy the WSP and install it.