Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am saving some masterpages to the file systems in some build scripts to automate the process of building deployment packages. This is what I am using to save the masterpages and layouts:

 using (var site = new SPSite("http://mysharepoint:2081"))
            {
                SPList masterPageGallery = site.GetCatalog(SPListTemplateType.MasterPageCatalog);
                foreach (SPListItem li in masterPageGallery.Items)
                {
                    if (EnumExtensions.ContainsDescription(typeof (MasterPageNames), li.File.Name) ||
                        EnumExtensions.ContainsDescription(typeof (PageLayoutNames), li.File.Name))
                    {
                        Console.WriteLine("Fetching - " + li.File.Name);
                        byte[] file = li.File.OpenBinary();
                        var fileStream = new FileStream(DeploymentLayoutsLocation + "\\" + li.File.Name,
                                                        FileMode.Truncate, FileAccess.Write);
                        fileStream.Write(file, 0, file.Length);
                        fileStream.Close();
                    }
                }
            }

Everyhting is exported correctly instead of my webpart information so for instance:

this:

<WebPartPages:WebPartZone id="WebPartZone_2" runat="server" title="Zone1" AllowLayoutChange="True" AllowCustomization="True"><ZoneTemplate>
    <WebUI:BrowserFormWebPart runat="server" AllowEdit="True" AllowConnect="True" SubmitBehavior="KeepOpen" ConnectionID="00000000-0000-0000-0000-000000000000" Title="Online Form" ></WebUI:BrowserFormWebPart>
</ZoneTemplate></WebPartPages:WebPartZone>

Comes out as:

<WebPartPages:WebPartZone id="WebPartZone_2" runat="server" title="Zone1" AllowLayoutChange="True" AllowCustomization="True"><ZoneTemplate></ZoneTemplate>
    </WebPartPages:WebPartZone>

Any Idea?

share|improve this question
    
Working as designed. WebPart instance data is not stored as part of the masterpage. –  Paul Schaeflein Jul 9 '12 at 13:11
    
Sure, but how can i Extract the full data. It must be possible because sharepoint designer does it... –  Luis Jul 10 '12 at 0:26
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.