November 2007 - Posts
I've posted on a couple of forums for SharePoint development and haven't received a response yet. The bottom line appears to be that regardless of whether or not you have WSS or MOSS loaded onto your machine, you will not get project or item templates for web parts. If someone knows what I'm missing, please post a comment.
In VS 08, I was able to pull in an existing web part and it did compile but I have to make my own wsp, manifest.xml, elements.xml and solution.xml files. I'll also have to take an existing batch file for easing deployments to client machines. Not a huge deal but a little painful. I hope to see some support offered soon from MS.
The configurations I tried are: MOSS + VS 08 and MOSS + VS 05 + VS 08. Interestingly, the msi for the SharePoint extensions CTP 1.1 installed without a hitch on a VM that didn't have VS 05. hmmm
So my MOSS VM decided to spend an hour running a check disk and recovering bad sectors. This is a very unhappy time when you think of all the code you didn't check in yet... One of my daughters had requested a Dr. Seuss book for bedtime and I was in a verse-ish kind of place... so here is how I spent that hour or so:
If your custom SharePoint project
isn't cookin' like it should
and your deployment situation's
falling flat, well then you could
give a read to this short rhyme
and grab your Stud'io Two Thousand Five
for it may help you unravel
all that's ravelled in your hive.
Two thousand eight will be out soon
you ought to get it quick
for it helps you get things done
that the old version couldn't lick.
SharePoint and the MOSS have grown
beyond a simple tool
so you'll need to get some help
to keep you sane, don't be a fool!
The M-S-D-N documents
are kind of hard to find
but some books can be quite helpful
and the the forum folks are kind.
Now deploying your solution
will depend on what you need
Because a content-type's a list
but not exactly, its agreed.
Will you push a form li-brary
or a web part for the req?
Or perhaps a site-based column'd
ease the pain that's in your neck?
Either way you said you'd follow
S-D-L-C so you ought
to make the final tested product
a package deal on the first shot
There are lots of bits and pieces
in this puzzle to deploy
Because that server's got a lot
of moving parts, its not a toy!
One way to get your stuff out
is to use a feature package
You can push it out and pull it back
and keep your audit trackage.
First you'll need a feature X-M-L
to make your product active
and place all your files in the same place
to be much more proactive.
The feature file contains the list
of things to bring online
and it also gives the Goo-ID
to make your system more refined.
You just copy the whole folder;
feature, files and X-M-L
and include the other docs you made
in programs like Excel.
But that's only the first step
there are still other steps to take
like the S-T-S command line tool
that's a little bit opaque.
You say install the feature
and it goes and does its thing
and if you force it you can redeploy
and really make it sing.
After the command line tool
has finished you can move
on to Central Admin
execution where you'll prove
that the work you did was proper
so you activate it now..
if all's well your feature's working
and you get to take a bow.
That's all that there is to it
and I can't be more precise
I learned it just a tick ago
(oh, and it seems my booze needs ice).
So no matter what you do, you are going to need to drop and modify things in the "12 hive" in SharePoint. I navigated to it exactly 3 times before I decided my best move would be to just create a shortcut. I made the shortcut to this folder:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ADMISAPI
because I wanted to have the entire 12 hive automatically opened up. I put the shortcut in My Documents so its always available when I explore the hard drive. I think this has already saved me a lot of time in the way of navigation.
I've been a keyboard-centric guy since Windows 3.1 and 3.11. Having one of the alt keys reserved for getting in and out of the VPC kills me every time. So go into your Virtual PC Console: "File" -> "Options". Select "Keyboard" and enter your new value. Since I nearly always go directly to MSDN or Google when I have a problem or question, it seemed natural to reallocate the F1 key for this.
Now, in place of Left Alt + Del to send the Alt + Ctl + Del combination to the VPC, I press F1 + Del. This makes my switches much more deliberate and, when I'm in full screen mode (F1 + Enter) on one screen I'm not automatically switching out when I press the stinkin alt key!
Create a warmup.bat file based on this blog post:
This will allow you to get all the appropriate services running as soon as you fire up your virtual machine. You are developing on a MOSS VM, right?
So the requirement presented to me for a client was to take an existing page layout and change a few of the properties to allow it to use some custom styles implemented at the site collection level. To do this, I needed to create a new page layout based on an existing layout, make this part of a feature and pull in all the bits and pieces necessary to deploy this as a feature. Finally, I had to deploy it to the client's testing environment.
Here is how I did it...
First, I was instructed that the Search Main Page was to be used as the starting point. A developer on my team told me the best way to go would be to load up SharePoint Designer, navigate to the appropriate document library and export the file. This didn't work. My requirement was to have the search web part already on the page, the same as the existing search main page. SharePoint Designer killed this web part tag so it came up empty.
Getting a copy of the page layout
1. Better is to go to the site collection you're starting with
2. Select "Site Actions" -> "Site Settings" -> "Modify All Site Settings"
3. Under "Galleries", select "Master pages and page layouts"
4. Find the page layout from the list and open its context menu, select "Send to" -> "Download a Copy"
5. Save the file to the solution location. We won't be using Visual Studio because its not necessary for this evolution.
6. Once the file is saved, reopen the context menu for the page layout file and select "View Properties".
7. Click on the Preview Image and when it appears, right click and save the image to the same location as the aspx file.
Now you have the basic aspx files you will modify and put back into SharePoint as a feature. Open the aspx page in an appropriate editor. I'm assuming you understand enough about aspx to do what you need to do. Make the appropriate modifications and save the file.
IMPORTANT NOTE: If you are like me, you have a desire to 'clean up' the file declarations so you can see what's going on. Don't do this. I haven't figured out why but when I introduced hard returns in the second line (the really long one) of declarations between <% %> sections, it bombed when I reimported it into SharePoint. A guy on the team here thinks there may be a checksum on that line to head off tampering. Dunno but I know when I leave it it works, when I touch it it bombs.
You can also use any editor (Paint.Net works) to change the page layout to look the way you want it to. Change the folder of this file to your feature folder + "\Images". It's required for the page layouts and master pages.
So you should have two files and a subfolder for your feature ready to go.
Now we need to set up the feature to deploy it.
1. Create two new files in any editor: "feature.xml" and "layoutfiles.xml"
2. Here are the contents of my feature.xml file:
Title="Custom Formatted Search Page Layout by Jim"
Description="Search page with customized style inclusions"
2.1. Id is a new GUID you generate from Visual Studio.
2.2. Scope means the level where this will be used, not the level at which it becomes available for items below it. So "Site" scope means it will be installed at the site collection level and used at the site level.
3. Here are the contents of my layoutfiles.xml file:
<Module Name="CustomSearchMain" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE">
<File Url="CustomFormattedSearch.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="$Resources:spscore,SearchMainTitle;" />
<Property Name="MasterPageDescription" Value="$Resources:spscore,SearchMainDescription;" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/Preview Images/customsearchpage.gif, ~SiteCollection/_catalogs/masterpage/Preview Images/customsearchpage.gif" />
<AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="1">
<Assembly>Microsoft.SharePoint.Portal, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<Module Name="LayoutPreviewImages" Url="_catalogs/masterpage/Preview Images" Path="Images" RootWebOnly="TRUE">
<File Url="customsearchpage.gif" Type="GhostableInLibrary"/>
3.1. I took most of this from a coleague and from the net. The CData portion gives you the embedded web part already in the top web part zone.
3.2. Notice the gif image parts of the xml. These are whatever the new name is for the gif you edited earlier.
3.3. Notice also the part that says: "contenttype_welcomepage_name". This means that your layout will appear under the "Welcome Page" templates when you go to use it in your site collection. I haven't found much about this on the web yet but I believe if you search on content types and master page libraries, you may find additional options.
Your feature is complete!
Now its time to deploy.
1. Copy your aspx, gif (in its folder) and 2 xml files to the server where you want to deploy and into a new temporary folder.
2. Copy from the temp location to the 12 hive \Template\Features\ folder.
3. Open a command line and run: stsadm.exe -o installfeature -name MyNewPageLayoutFeature -force
3.1. Use the -force option if you've already installed previously.
3.2. the -name value is the name of the folder where the your feature now exists in the 12 hive.
4. Execute iisreset
5. Browse the the appropriate site collection on your server and back to "Site Actions" -> "Site Settings" -> "Modify All Site Settings"
6. Under "Site Collection Administration" select "Site Collection Features"
7. You should see your new feature/page layout. Click to activate.
Use your new layout.
Now, when you go to create a new page, you should see your additional layout. When you select it, you should get your custom layout gif to show users what it will look like.
I can imagine really intricate uses of this for creating custom CRM dashboards or for magically including SilverLight applications in your system. Good Luck!