MOSS 2007 - Custom Aspx Pages Created With Feature - sharepoint

(I have also asked this question on SharePoint Overflow.)
I have a SharePoint feature I'm using to add some custom aspx files to the Pages Library.
When I activate the feature, I can visit the pages in-browser and they are visible in SPDesigner, but when I "View All Site Content" they are not there.
Why is this the case?
The Feature's Elements File:
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" IgnoreIfAlreadyExists="False">
<Property Name="Title" Value="The Example" />
<Property Name="ContentType" Value="Page" />
</File>
</Module>
</Elements>
The Aspx File:
<%# Page language="C#" Inherits="System.Web.UI.Page,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" MasterPageFile="~masterurl/default.master"%>
<%-- deliberately left empty -->
(yup, it's empty!)
Addendum
When I "visit the pages in-browser" I mean navigate to their URLs manually: http://myserver:PORT/subsite/Pages/Example.aspx
When I "View All Site Content" I am looking at the contents of the "Pages" list: http://myserver:PORT/subsite/Pages/Forms/AllItems.aspx

I got an answer on SharePoint Overflow:
The File Node should have Type="GhostableInLibrary", because "Pages" is a document library. When ever you provision a file in a document library you need to have ghostableinlibrary set.
eg:
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="False">
<Property Name="Title" Value="The Example" />
<Property Name="ContentType" Value="Page" />
</File>
</Module>
</Elements>
So in the end the XML I'm using is...
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="9e85eb79-6d8d-4ff3-b0d4-64d55c3bb577" xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Pages" Url="Pages">
<File Path="Example.aspx" Url="Example.aspx" IgnoreIfAlreadyExists="False" Type="GhostableInLibrary">
<Property Name="Title" Value="The Example" />
</File>
</Module>
</Elements>

Related

wix installer / Create web-site and assign the new or exisiting web app pool

i try create a new web-site using wix installation. it's ok there is no problem but i cannot assign a new or existing web app pool to new web-site. iis:website tag does not contains WebAppPool attribute. How can i assign web app pool to web-site. You can see my code bellow.
thanks for helping.
<Component Id="WEB_SITE_CONFIGURE_COMPONENT" Guid="{35087032-D049-48C8-BCAD-1FEFD0C06A25}" NeverOverwrite="yes" Shared="yes" Permanent="yes" Transitive="yes">
<Condition><![CDATA[WEBSITE_INSTALLTYPE<>2]]></Condition>
<CreateFolder Directory="WEBSITE_FOLDER"/>
<iis:WebSite Id="WEB_SITE" Description="[WEBSITE_NAME]" SiteId="*" Directory="WEBSITE_FOLDER" ConfigureIfExists="yes" AutoStart="yes" StartOnInstall="yes">
<iis:WebAddress Id="AllUnassigned" Port="[WEBSITE_PORT]" />
</iis:WebSite>
<RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigSite" Value="1" Type="string"></RegistryValue>
</Component>
<Component Id="WEBAPP_POOL_CONFIGURE_COMPONENT" Guid="{316738A6-26A2-4C14-9AB9-B2066E3FA288}" KeyPath="yes" Permanent="yes" Transitive="yes">
<Condition><![CDATA[(WEBSITE_INSTALLTYPE=0) OR (USE_CUSTOM_WEBSITE_FOLDER=1)]]></Condition>
<iis:WebAppPool Id="APP_POOL" Name="[WEBAPP_POOL_NAME]" ManagedPipelineMode="Classic" ManagedRuntimeVersion="v4.0"/>
<RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigPool" Value="1" Type="string"></RegistryValue>
</Component>
<Component Id="WEPAPP_CONFIGURE_COMPONENT" Guid="{F95B024E-B6B6-4E6C-AC35-9B1086FC3521}" Transitive="yes">
<Condition><![CDATA[(WEBSITE_INSTALLTYPE<>2) AND ((WEBSITE_INSTALLTYPE=0) OR (USE_CUSTOM_WEBSITE_FOLDER=1))]]></Condition>
<iis:WebVirtualDir Id="VIRTUAL_DIR" Alias="[WEB_APP_NAME]" Directory="WWW_FOLDER" WebSite="WEB_SITE">
<iis:WebApplication Id="WEB_APP" Name="[WEB_APP_NAME]" WebAppPool="APP_POOL"/>
</iis:WebVirtualDir>
<RegistryValue Root="HKLM" Key="$(var.DefaultRegistryKey)" Name="ConfigVirtualDir" Value="1" Type="string"></RegistryValue>
</Component>
With the help of the following articles I have come up with a working installer in which a new AppPool can be created or an existing AppPool can be selected.
Creating a Web Application Installer with WIX 3.5 and Visual Studio 2010–Part 1
Web Application Installer in WiX
WiX and DTF: Using a Custom Action to list available web sites on IIS
Installing a Web Application to an Existing IIS Website using Wix3
In short:
Create a Website element in your Product element:
<Product>
<iis:WebSite Id="SelectedWebSite" Description="[WEBSITE_DESCRIPTION]" Directory="INSTALLFOLDER" SiteId="[WEBSITE_ID]">
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
</Product>
Create an Include WebSites.wxi with the following content:
<?xml version="1.0" encoding="utf-8"?>
<Include>
<Property Id="WEBSITE_DESCRIPTION">
<RegistrySearch Id="WebSiteDescription" Name="WebSiteDescription" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
</Property>
<Property Id="WEBSITE_ID">
<RegistrySearch Id="WebSiteID" Name="WebSiteID" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
</Property>
<Property Id="WEBSITE_PATH">
<RegistrySearch Id="WebSitePath" Name="WebSitePath" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
</Property>
<Property Id="WEBSITE_VD">
<RegistrySearch Id="WebSiteVD" Name="WebSiteVD" Root="HKLM" Key="SOFTWARE\!(loc.CompanyName)\[ProductName]\Install" Type="raw" />
</Property>
<CustomTable Id="AvailableWebSites">
<Column Id="WebSiteID" Category="Identifier" PrimaryKey="yes" Type="int" Width="4"/>
<Column Id="WebSiteDescription" Category="Text" Type="string" PrimaryKey="no"/>
<Column Id="WebSitePath" Category="Text" Type="string" PrimaryKey="no" Nullable="yes"/>
<Row>
<Data Column="WebSiteID">0</Data>
<Data Column="WebSiteDescription">Dummy</Data>
<Data Column="WebSitePath"></Data>
</Row>
</CustomTable>
</Include>
Create the CustomAction described here.
Create a wxs file with your AppPool:
<?xml version="1.0" encoding="UTF-8"?>
<Wix
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Fragment>
<Component Id="WebVirtualDirComponent" Guid="PUT-GUID-HERE" Directory="INSTALLFOLDER" KeyPath="yes">
<iis:WebAppPool
Id="YourAppPoolName"
Name="[VD][WEBSITE_ID]"
ManagedRuntimeVersion="v4.0"
IdleTimeout="0"
RecycleMinutes="0"
ManagedPipelineMode="integrated"/>
<iis:WebVirtualDir Id="VDir" Alias="[VD]" Directory="INSTALLFOLDER" WebSite="SelectedWebSite">
<iis:WebApplication Id="NotizBrowserWebApp" WebAppPool="YourAppPoolName" Name="[VD][WEBSITE_ID]" />
<iis:WebDirProperties Id="NotizBrowserProps" AnonymousAccess="no" WindowsAuthentication="yes" DefaultDocuments="-" Execute="yes" Script="yes" Read="yes"/>
</iis:WebVirtualDir>
</Component>
</Fragment>
</Wix>
Late answer, but hopefully someone will be benefited with this.
You don't need a CustomAction to make this work.
It is simple like this:
<Component Id="WebSite" Guid="PUT-YOUR-GUID-HERE">
<CreateFolder/>
<iis:WebSite Id="WebSite" Directory="WebSiteRoot" Description="[WEBSITEDESCRIPTION]" >
<iis:WebApplication Id="WebSiteApplication" Name="[WEBSITEDESCRIPTION]" WebAppPool="MyAppPool" />
</iis:WebSite>
<iis:WebAppPool Id="MyAppPool" Name="[APPPOOLNAME]" ManagedRuntimeVersion="v4.0"/>
</Component>
You need to update the "Internal" WebApplication of the WebSite.
You don't need to have the "WebSite Description" and "WebApplication Name" equal, but that will help you to understand what is going on.

Provisioning a default.aspx page to use a custom page layout

I have a custom site definition I created that deploys a couple of custom page layouts. Does anyone know what needs to be done so that when a user uses my site definition to create a site, their default.aspx page is created using my custom page layout?
Below is the module section of my site definition:
<Modules>
<Module Name="DefaultHome" Url="$Resources:osrvcore,List_Pages_UrlName;" Path="">
<File Url="default.aspx" Type="GhostableInLibrary" >
<Property Name="Title" Value="Test Home Page" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyCustomPageLayout.aspx, My Custom PageLayout" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
<Property Name="PublishingPageContent" Value="Welcome to the My Test Publishing Site" />
</File>
</Module>
</Modules>
In your onet.xml file you need to set the DefaultPageLayout property like below
<!-- Publishing Feature -->
<Feature ID="22A9EF51-737B-4ff2-9346-694633FE4416">
<Properties xmlns="http://schemas.microsoft.com/sharepoint/">
<Property Key="WelcomePageUrl" Value="$Resources:osrvcore,List_Pages_UrlName;/Default.aspx" />
<Property Key="ChromeMasterUrl" Value="~SiteCollection/_catalogs/masterpage/MyMasterPage.master"/>
<Property Key="SimplePublishing" Value="True" />
<Property Key="VersioningOnPages" Value="Major" />
<Property Key="RequireCheckoutOnPages" Value="False" />
<Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx:~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
<Property Key="DefaultPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx"/>
<Property Key="AvailableWebTemplates" Value="ENTERWIKIRBKC#2;"/>
<Property Key="AllowSpacesInNewPageName" Value="false"/>
</Properties>
</Feature>
The default.aspx page in SiteDefinition created by VS inherits from webpart page. Make sure that you delete all the code and add the below. This has worked for me.
<%# Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%# Reference VirtualPath="~TemplatePageUrl" %>
<%# Reference VirtualPath="~masterurl/custom.master" %>

Sharepoint 2010 WSP Deployment problem. Can’t deploy new files

We have found a problem with our deployment to a production server that runs Sharepoint 2010 Publishing Site Collection.
We are deploying WSP packaged from Visual Studio to Sharepoint Management Shell (Uninstall, reinstall solution). It has worked like a charm in the past. We added a custom masterpage, css files, images and later we successfully added custom page layouts.
I also have SP running locally on my computer and everything works fine with no problem adding new files via deploying Feature. I can add them neatly into a document library or even create new folders from the Elements file.
However the problem arise when I deploy my WSP to the production server. I want to add a few JS files and a XSL file to the Style Library but the files won't get added to the document library. The deployment process goes smooth though with no errors and when I check my feature in Sharepoint Hive, the new files are there on the physical drive! However they won't get added to the virtual Document Library.
I can update existing files like the masterpage and CSS files so the feature that is deployed is working.
My guess is that either it has to do with permission problems or some bug in my code. But I did exactly as we have done before when deploying.
This is how my Elements.xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="ALayout" Url="_catalogs/masterpage" RootWebOnly="true" >
<File Path="ALayout\_a_intra.master" Url="_a_intra.master" Type="GhostableInLibrary" />
</Module>
<Module Name="ALayoutStyles" Url="Style Library" RootWebOnly="true" >
<File Path="ALayout\styles\z_aintra_core.css" Url="z_aintra_core.css" />
<File Path="ALayout\styles\aintra_std.css" Url="aintra_std.css" />
</Module>
<Module Name="ALayoutStyleImages" Url="Style Library/img" RootWebOnly="true" >
<File Path="ALayout\styles\img\a-logobig.png" Url="a-logobig.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\bg.png" Url="bg.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\divider.png" Url="divider.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-bg-hovered.png" Url="nav-bg-hovered.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-bg-radius-left.png" Url="nav-bg-radius-left.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-bg-radius-right.png" Url="nav-bg-radius-right.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-bg-selected.png" Url="nav-bg-selected.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-bg.png" Url="nav-bg.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\nav-divider.png" Url="nav-divider.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\top_bg.png" Url="top_bg.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\user-account-radius-left.png" Url="user-account-radius-left.png" Type="GhostableInLibrary" />
<File Path="ALayout\styles\img\user-account-radius-right.png" Url="user-account-radius-right.png" Type="GhostableInLibrary" />
</Module>
<Module Name="ALayoutScript" Url="Style Library/js" RootWebOnly="true" >
<File Path="ALayout\js\script.js" Url="script.js" Type="GhostableInLibrary" />
<File Path="ALayout\js\plugins.js" Url="plugins.js" Type="GhostableInLibrary" />
</Module>
<Module Name="ALayoutScriptLibs" Url="Style Library/js/libs" RootWebOnly="true" >
<File Path="ALayout\js\libs\jquery-1.4.2.min.js" Url="jquery-1.4.2.min.js" Type="GhostableInLibrary" />
</Module>
</Elements>
The last two modules (for Javascript) is the ones I can't deploy to the document library. I tried different document libraries but it still doesn't work on production server, just locally. And I can't deploy to Sharepoint Hive via Feature.
Anyone can think of something I missed?
Wow, the solution was simple. I deactivated the feature in Sharepoint administration, and reactivated it and the new files got deployed.
WHY this happened, I don't know. If I version my feature instead of uninstall->add it might get fixed?
Why is the behavior different on the production farm vs local? etc.
There are few points I want yo bring to your notice. Just check if you are already following them...
I hope you have "js" folder in your VS solution (under ALayout module).
Add IgnoreIfAlreadyExists="FALSE" attribute to the node
File Path="ALayout\js\libs\jquery-1.4.2.min.js" Url="jquery-1.4.2.min.js" Type="GhostableInLibrary" IgnoreIfAlreadyExists="FALSE"/
Use ULSViewer to see any errors while deploying on production...

SharePoint > Custom Page-Library & PageLayout

I have a custom page-library which a custom content-type and a page-layout all inside a site-definition.
Works as expected. The only thing I cannot get around is that if I upgrade the solution with the page-lib, ctype, page-layout via stsadm everything is updated except the page-layout.
New fields in the ctype --> no problem
Changed views in the page-lib --> no problem
Updated PageLayout --> ERROR
The page-layout section:
<!-- specific page-layout to display LKW data -->
<File Url="CustomPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >
<Property Name="Title" Value="$Resources:CustomLayouts,Title;" />
<Property Name="MasterPageDescription"
Value="$Resources:cmscore,PageLayout_BlankWebPartPage_Description;" />
<Property Name="ContentType"
Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingPreviewImage"
Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png" />
<Property Name="PublishingAssociatedContentType"
Value=";#$Resources:FieldsCTypes,cTypeDisplayName;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900D38AAFB8072F441984BC947D49503947;#" />
</File>
The relevant section in the onet.xml:
<Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;Custom" Path="">
<File Url="Default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title"
Value="$Resources:Layouts,DisplayName;" />
<Property Name="ContentType"
Value="$Resources:cmscore,contenttype_welcomepage_name;"/>
<Property Name="PublishingPageLayout"
Value="~SiteCollection/_catalogs/masterpage/CustomPage.aspx, $Resources:PalfingerPlatformsOrderRoot,LKWpageDefaultTitle;" />
<Property Name="PublishingPageContent"
Value="" />
</File>
</Module>
The strange thing is, if I just have a page-layout with no underlying page-library I can update the page-ayout.
The problem only occurs if I use a custom page-layout inside a custom page-library.
I did some Google search and found a hint - the problem could be that the page-layout is unghosted.
I checked this with a small sample code:
SPFile file = folder.Files["Default.aspx"];
if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized)
{
file.RevertContentStream();
}
After executing the code the Page-Layout is upgraded and uses the new page-layout.
The Problem is that this is no real solution for me because I have approx. 1000 site-collections using the site-def. and the page-layout.
Updating all of them is quite painful. Does anybody know a solution for this?
I would like to comment on one thing. Looks like IgnoreIfAlreadyExists="TRUE" is not working properly refer to this link, may be reverting the value to FALSE should help.
<File Url="CustomPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" >

Add webpart to default WSS page via feature

I've developed a custom web part. I would like to create a feature that when activated via STSADM adds the web part to the default page of a WSS Site. Hopefully this can be done without writing code.
This webpart is meant to de deployed to the web application's bin directory and featurereceiver must be installed to the GAC. The AllUsersWebPart element looks promising, but I can't figure out how to get it to work.
TIA,
jt
The AllUsersWebPart tag allow us to insert one webpart and place it where we want using WebPartOrder and WebPartZone attributes. The content of the tag is the dwp (or webpart) of your webpart. For example, for a dwp:
<AllUsersWebPart WebPartZoneID="MiddleLeftZone" WebPartOrder="0">
<![CDATA[
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
<FrameType>None</FrameType>
<AllowMinimize>true</AllowMinimize>
<IsVisible>true</IsVisible>
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Value><iframe src="$Resources:Summary_Url;" frameborder="0" scrolling="no" width="100%" height="100%"></iframe></Value>
</Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
]]>
</AllUsersWebPart>
For a webpart:
<AllUsersWebPart WebPartZoneID="MiddleLeftZone" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f3b9d1137704f880" />
<importErrorMessage>No se puede importar este elemento Web.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="AllowClose" type="bool">False</property>
<property name="AllowMinimize" type="bool">False</property>
<property name="AllowConnect" type="bool">True</property>
<property name="ChromeType" type="chrometype">None</property>
<property name="Hidden" type="bool">False</property>
<property name="AllowEdit" type="bool">False</property>
<property name="AllowZoneChange" type="bool">False</property>
<property name="MissingAssembly" type="string">No se puede importar este elemento Web.</property>
<property name="ChromeState" type="chromestate">Normal</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</AllUsersWebPart>
I haven't tried before but I think it can be done once the web has been created. Try it and tell us.

Resources