Home Contact

The Frog Pond of Technology

Ripples of Knowledge for SharePoint and Other .Net Technologies

News

My blog has moved to WordPress at BrianTJackett.com. Any pages will automatically redirect to the new address in 7 seconds. Please excuse an issues during this migration.

 Subscribe to this blog


About Me

Name:
Brian T. Jackett
Location:
Columbus, OH
Company:
Microsoft

Find me on...

Tag Cloud


Archives

Post Categories

Syndication:

Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

    In a previous post, I mentioned having an issue deploying SharePoint solution files to a non-12 Hive locations on all web front ends (WFEs).  The problem I faced was that WSPBuilder doesn’t allow me to edit the manifest.xml file (reference, near bottom) and my custom code to copy the files was successful, but only executing on the WFE from which the feature activation command was being called.  Once we moved to a multiple WFE environment all of the other WFEs were missing files.

    The always helpful Sean McDonough suggested that I use an SharePoint Timer job because that will execute code on all WFEs.  I had never built a custom timer job so I researched the links Sean shared and dove head first into it.  I had moderate success but ran into an issue with the account running my timer job (which ended up being the Farm Access account) not having write permissions to the non-12 Hive location as it was not a local admin on every WFE in the farm.  The solution to that problem (another blog post forthcoming on solving that ACL permission issue) was looping through the WFEs during feature activation.  As it turns out, discovering that I could loop through each WFE led to a much simpler solution to my original problem.2007-02-13-Ockhams_Razor    Any of you familiar with Occam’s Razor (also spelled Ockham) will realize that simpler solutions are almost always the better solution.  So instead of wiring up a feature to set write permissions, then store needed values in a property bag, and then kick off a timer job I went with a much simpler solution.  Below is a code snippet for how to deploy SharePoint solution files to a non-12 Hive location on multiple web front ends without using a timer job (wow that’s a mouthful.)

    The files I am deploying are a set of support files for the RadEditor for MOSS Lite Edition that need to live in the “wpresources” folder (which is a sibling folder of the 12-Hive.)  I originally deploy the files to a subfolder “Support Files” of the feature root folder.  From there they are copied to the appropriate location within “wpresources”.  You may also download the code snippet from my SkyDrive here.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    // set source and destination folders
    string sourceFolder = properties.Definition.RootDirectory + @"\Support Files\";
    string destinationFolder = properties.Definition.RootDirectory + @"\..\..\..\..\wpresources\RadEditorSharePoint\4.5.6.0__1f131a624888eeed\RadControls\Editor\";
    List<string> filesToDeploy = new List<string>();
 
    // dynamically find all files in the source folder
    DirectoryInfo folder = new DirectoryInfo(sourceFolder);
    FileInfo[] filesInFolder = folder.GetFiles();
    foreach (FileInfo file in filesInFolder)
    {
        filesToDeploy.Add(file.Name);
    }
 
    // recurse through each web front end
    foreach (SPServer server in properties.Definition.Farm.Servers)
    {
        if (server.Role == SPServerRole.WebFrontEnd)
        {
            // copy support files per web front end
            foreach (string filename in filesToDeploy)
            {
                try
                {
                    // reference files based on network share format (\\serverName\C$\...)
                    string sourceFile = @"\\" + server.Address + @"\" + sourceFolder.Replace(":", "$") + @"\" + filename;
                    string destinationFile = @"\\" + server.Address + @"\" + destinationFolder.Replace(":", "$") + @"\" + filename;
 
                    System.IO.File.Copy(sourceFile, destinationFile, true);
                }
                catch (Exception ex)
                {
                    // ..exception handling goes here
                }
            }
        }
    }
}

    As far as I can tell my research didn’t turn up any other results on this topic so this may be me blazing some trails on the subject matter.  If you have any questions, comments, or feedback please feel free to leave some below.  I’ll update this post with a link to my forthcoming post on setting ACL permissions during feature activate.  Happy SharePointing.

 

      -Frog Out


Wednesday, December 30, 2009 8:35 AM

Feedback

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

What happens when you add a WFE to your farm? The feature is already activated so this will not add the files to the new WFE I think. 12/30/2009 8:53 AM | Matthijs Hoekstra

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Brian,

Nice job! When I mentioned that I was "curious" the other day, I was wondering if you might go the file copy route with SPServer (since it's one of the few types that actually maps to something "physical" in the farm).

This looks like a very straightforward approach, and as an added bonus, it looks like one that should be relatively easy to troubleshoot (from a code perspective) if problems do arise -- no wrangling with SharePoint beyond the fact that this happens in a FeatureReceiver.

A couple of watch-outs (or rather, points of awareness) for readers; the chances of these being actual issues are generally pretty small in all but the most security conscious of environments:

1. Admin shares are employed during copy. Some administrators restrict or lockdown server admin shares, so if problems are encountered during the copy operations, one of those uncomfortable "admin-developer dialogs" might ensue. :-)

2. Obviously, file-sharing being open between the activation box (typically the Central Admin host) and each WFE is assumed. In locked-down environments, SMB traffic (typically locked down to TCP and UDP port 445 for non-NBT file sharing) needs to be permitted between servers -- not blocked by firewalls, IPSec rules, etc.

Again, great solution, Brian. I'll definitely be adding this approach to my arsenal. Thanks for sharing! 12/30/2009 9:07 AM | Sean McDonough

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Matthijs,
When adding a WFE to the farm, SharePoint automatically adds all solutions and activates all features that are already deployed to the rest of the farm (one of my favorite advantages of SharePoint solutions.) I believe it performs a local add and deploy to the new server, but don't quote me on that. My initial testing shows that the files (as in the above case) are properly deployed to the target location. 12/30/2009 9:25 AM | Brian Jackett

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Sean,
Thanks for the feedback. You are correct that I am assuming the network shares and appropriate permissions are already in place. There is a very limited chance that security settings in your environment would be blocking access, but hopefully through debugging and exception handling that would be discovered quickly.
On a related note, I was able to use your SPTimer job suggestion to solve a different problem on my current project. Thanks for pointing me in that direction. 12/30/2009 9:30 AM | Brian Jackett

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Like this. A simple and effective solution. About to venture into Timer job route, but came across this. Will give a shot at this.

Appreciate thinking differently when whole herd (me including) was going timer job way 12/31/2009 12:53 AM | Raju

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Raju,
Thanks for the feedback, glad you like. I was very happy with this solution as well. Timer jobs are sometimes the right solution for certain scenarios which I found to be the case on different issue I was tackling. More on that coming soon. 12/31/2009 9:04 AM | Brian Jackett

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Hi Brian,

Thanks for all your posts. When I tried this solution, it doesnt return correct server address, it says "\\Exch-smtp" for server address...I am worndering why...??
Can you please suggest..?

Thanks
Nisha 1/20/2010 5:13 PM | Nisha

# re: Deploying SharePoint Solution Files to Non-12 Hive Locations on Multiple Web Front Ends

Nisha,

By the looks of your server name "Exch-smtp" I would guess that's an Exchange/SMTP server. When you enter the foreach loop and iterate through the servers, you'll get every server associated with the farm. This includes application, database, index, SMTP, web front end, and any other type of servers.

The first line of my foreach loop filters that list to make sure we are only working with web front ends after that. Make sure that if statement is included. Also check that the server in question indeed shouldn't be considered a web front end. It may be mistakenly hosting content when it shouldn't. You can fix an issue like that by changing the settings in Services on Server within Central Administration.

Hope this helps. Let me know if you have further questions. 1/20/2010 7:34 PM | Brian Jackett

Post A Comment
Title:
Name:
Email:
Comment:
Verification: