SharePoint User Group UK

Share the knowledge!

Welcome to SharePoint User Group UK Sign in | Join | Help
in
Home Blogs Forums Photos Files Roller

MsBuild task accessing Sharepoint SPFarm fails

Last post 04-22-2008, 11:54 AM by wozza. 0 replies.
Sort Posts: Previous Next
  •  04-22-2008, 11:54 AM 10046

    MsBuild task accessing Sharepoint SPFarm fails

    I  have an MsBuild task that I am writing, which works fine on my dev machine, but when I run it on our production environment, It cannot instantiate the SPFarm object ... even though the user I am logged on to the server as is a farm administrator.

    The code below throws an error ...      

    using WSSAdmin = Microsoft.SharePoint.Administration;

    WSSAdmin.SPFarm oFarm = WSSAdmin.SPFarm.Local;
                    if (oFarm == null)
                    {
                        throw new ApplicationException("Can't get Local SPFarm. Make sure you are member of 'Farm Admins' group");
                    }

    Interestingly, if I run the code above from a simple command line application it works fine .... so I am (now) assuming that it is something to do with MsBuild ...

    Can anyone suggest what I need to do to get this to run in MsBuild successfully?

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems