Friday, August 15, 2008

OT: It's easy to write for Sharepoint... (they tell me)

I was meandering through the blogosphere over lunch and came to this priceless post written by Paul Andrew, Microsoft Technical Product Manager for the SharePoint Developer Platform.

Write Your First SharePoint Program

To write SharePoint code you need:
  1. SharePoint installed on your local development machine and this means you need to run Windows Server 2003 or Windows Server 2008. VPCs are available here. There is a SharePoint one, or you can get a smaller base and add WSS or MOSS to it.
  2. Get Visual Studio 2005 Professional or above, the Visual Studio 2005 extensions for Windows SharePoint Services 3.0, v1.1 and the Visual Studio 2005 extensions for Windows Workflow Foundation (Visual Studio 2008 support is planned for June 2008).
  3. Get the WSS SDK and the MOSS SDK. They are also available online for WSS and MOSS.
  4. Start Visual Studio on your Windows Server machine that has SharePoint installed and create a new Windows Console Application. Yes there are SharePoint project templates, but I'm going for a fast first SharePoint program here and we don't need them yet.
  5. If you are on Windows Server 2008 then make sure you started Visual Studio by right click and run as administrator.
  6. Add a reference to Microsoft.SharePoint.dll (shown in references as Windows SharePoint Services)
  7. Add a using Microsoft.SharePoint
  8. Add this code:

static void Main(string[] args)
{
// Update to your server name
using (SPSite siteCollection = new SPSite("http://localhost"))
{

SPWebCollection site = siteCollection.AllWebs;
foreach (SPWeb web in site)

{
try
{

SPListCollection lists = web.Lists;

Console.WriteLine("Site: {0} Lists: {1}",

web.Name, lists.Count.ToString());

foreach (SPList list in lists)

{

Console.WriteLine("List: {0} {1}",

list.Title, list.ID.ToString());

}

}

//catch (Exception)

//{

// // handle

// throw;

//}

finally

{

web.Dispose();

}

}

} // dispose is called on site as a result of using()

Console.WriteLine("Press ENTER to continue");

Console.ReadLine();

}


9. Run it with F5



So maybe I've been spoiled by working with Domino too long but I really don't think it should be that difficult to write your first program for any application. Whatever happened to "Hello World"?

Can some Sharepoint developer tell me if it really is that complicated to get Sharepoint set up and running for the developer environment. Surely there is an easier place to start (not that I intend to be using it).
.

1 comment:

Gavin Bollard said...

There's a couple of lovely articles by developers who've moved to the joys of sharepoint linked below;

I Hate Sharepoint: How a tiny project turned into a big headache because of poor platform choice!?"

and

I'm a developer, and I hate SharePoint

mmmm... sounds good.