Archives

Archives / 2007 / May
  • Generate a list of GUID's

    Sometimes you just need a lot of GUID's while programming.  Ofcourse you could use the Visual Studio GUID tool, bu that is a lot of work.

    Open a PowerShell console, and paste in the following line to get a list of 100 guid's:

    $i=100; while ($i-- -gt 0) { Write-Host ([System.Guid]::NewGuid()) }

  • Factories @ Macaw - the DotNed presentation of april 26, 2007

    On april 26, 2007 I gave a presentation at the Macaw headquarters in Schiphol-Rijk, The Netherlands on what we are doing with Software Factories at Macaw.

    I promised the audience to publish some links to tools and information mentioned in the presentation. I can't upload the presentation itself because it was a real "look into the kitchen of..." session with information that we can't give away (yet). I promise to blog more on this in the future however.

    Some initial posts on what we are working on:

    Tools we are using to realize our software factory vision:

    I hope you all had an informative session and got some "food for thought" ob what you could do within your organization. If you would like to leave a comment on what your impression of the presentation, please do so as a comment to this blog post, or send me a direct e-mail at serge@macaw.nl!

  • SharePoint Features - elements, scope and other info

    When designing features for SharePoint 2007 you always have to think about the scope where the feature should be executed: Web, Site, WebApplication or Farm. Microsoft has a nice table in its documentation that gives insight in what can be done where. Bram, thanks for pointing this out to me!! For more information on what these features do see this documentation by microsoft. Below I do some hyperlinking/annotation on this information to give you quick(er) access to the wonderful world named features...

    The article is not finished yet, I would like to link to interesting blog posts etc, but don't have the time right now. It might be useful as it is right now. If you have other info to link in, let me know (as a comment) and I will update the post.


    SCOPE AND ALLOWED FEATURES

     

     

    Web (Web site)

    Site (site collection)

    WebApplication (Web application)

    Farm (farm)


    DETAILED EXPLANATION OF THE FEATURES

     

     

    Content Type (Site)

    Contains a schema definition you can reuse and apply to multiple list definitions.

    Links:


     

    Content Type Binding (Site)

    Content type binding enables you to provision a content type on a list defined in the onet.xml schema. Lists defined in the onet.xml schema cannot be modified directly.

    Links:


    Control (Farm, WebApplication, Site, Web)

    A delegate control contains a registration for a well-known control installed on a Web page. This lets you replace existing controls, such as the Windows SharePoint Services search control, with another control.

    Links:


    Custom Action (Farm, WebApplication, Site, Web)

    You can define the following kinds of custom actions:

    • Content type links for the content type settings page

    • Drop-down menu actions for the drop-down menu that appears for an item

    • Form toolbar buttons for New, Edit, or Display form toolbars.

    • Site Settings link for the Site Settings page.

     In a custom action it is often required to pass context arguments on the URL in the <UrlAction> tag. This in done with URL Tokens.

    The following URL tokens are supported:

    Windows SharePoint Services supports the following tokens with which to start a relative URL:

    • ~site - Web site (SPWeb) relative link.
    • ~sitecollection - site collection (SPSite) relative link.

    In addition, you can use the following tokens within a URL:

    • {ItemId} - Integer ID that represents the item within a list.
    • {ItemUrl} - URL of the item being acted upon. Only work for documents in libraries. [Not functional in Beta 2]
    • {ListId} - GUID that represents the list.
    • {SiteUrl} - URL of the Web site (SPWeb).
    • {RecurrenceId} - Recurrence index. This token is not supported for use in the context menus of list items.

    Procedures

    Links:


    Custom Action Group (Farm, WebApplication, Site, Web)

    Defines a group of custom actions.

    Links:


    Document Converter (WebApplication)

    Contains the definition of a document converter. A document converter is a custom executable file that takes a document of one file type, and generates a copy of that file in another file type.


    Feature/Site Template Association (Farm, WebApplication, Site)

    Binds a feature to a site definition or template so that created sites are provisioned with the feature.


    Field (Site)

    Contains a field definition that can be reused among multiple lists.


    Hide Custom Action (Farm, WebApplication, Site, Web)

    Hides a custom action that has been added through another custom action.

    Links:


    List Instance (Site, Web)

    Provisions a SharePoint site with a specific list of data.


    List Template (Site, Web)

    Contains a list definition or template, which defines a list that can be provisioned in a SharePoint site.


    Module (Site, Web)

    Contains a set of files with which to provision sites.


    Receiver (Web)

    Contains an item event receiver registration.


    Workflow (Site)

    Contains the definition for a workflow in a list.

     


    OTHER INTERESTING INFORMATION 

     

    Features and element files

    In order to ensure that the feature can be properly upgraded all files belonging to the feature should be included in <ElementFile> tags. If files are not properly defined in <ElementFile> tags they will not always be upgraded when the feature is upgraded. [Source: Jussi Palo]


    OTHER LINKS 

     

    Activation Dependencies and Scope - How dependency between features is handled in the context of scope

  • MsBuild: sort your Content item file names

    I have been playing a bit with MsBuild to process a set of Content items sorted by file name. Content items are the items included in the project, and their Build Action set to Content. Below some sample code on how to achive this, just paste the code in a file sorttest.msbuild, and run as msbuild.exe sorttest.msbuild.

     

    <?xml version="1.0" encoding="utf-8"?>
    <Project DefaultTargets="SortTest"
        xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
    
      <PropertyGroup>
        <SortCommand>$(WinDir)\System32\sort.exe</SortCommand>
        <ContentItemsSortInFile>$(TEMP)\sortfileIn.tmp</ContentItemsSortInFile>
        <ContentItemsSortOutFile>$(TEMP)\sortfileOut.tmp</ContentItemsSortOutFile>
      </PropertyGroup>
    
      <ItemGroup>
        <Content Include="SampleNorthwind\0002_content.testdata.sql" />
        <Content Include="SampleNorthwind\0001_initial.schema.sql" />
        <Content Include="SampleNorthwind\0004_employee-mobilephone.schema.sql" />
        <Content Include="SampleNorthwind\0003_constraints.schema.sql" />
      </ItemGroup>
    
      <Target Name="SortTest">
        <WriteLinesToFile
                  File="$(ContentItemsSortInFile)"
                  Lines="@(Content)"
                  Overwrite="true"/>
        <Exec Command="$(SortCommand) $(ContentItemsSortInFile) > $(ContentItemsSortOutFile)"/>
        <ReadLinesFromFile File="$(ContentItemsSortOutFile)">
          <Output TaskParameter="Lines" ItemName="SortedContent"/>
        </ReadLinesFromFile>
        <!-- CLEAN UP TEMPORARY FILES -->
        <Delete Files="$(ContentItemsSortInFile)"/>
        <Delete Files="$(ContentItemsSortOutFile)"/>
    
        <!-- DO YOUR ACTION WITH SortedContent, FOR NOW, JUST WRITE IT OUT, ',' SEPARATED -->
        <Message Text="@(SortedContent,',')"/>
      </Target>
    </Project>
    
    

    UPDATED:

     

    My collegue Dion Olsthoorn came with the following solution that is smarter:

    • Get the files from filesystem, is sorted by default
    • Determine all files NOT in project
    • Get again files from filesystem, exclude files NOT in project
    • Result is a set of sorted items as included in the project (as Content items)

    Nifty nifty!

    Replace this target in the code above:

    <Target Name="SortTest" Outputs="%(Content.RelativeDir)">

                    <CreateItem Include="%(Content.RelativeDir)*" Exclude="@(Content)">

                                   <Output TaskParameter="Include" ItemName="ExcludedSortedContent"/>

                    </CreateItem>

                    <CreateItem Include="%(Content.RelativeDir)*" Exclude="@(ExcludedSortedContent)">

                                   <Output TaskParameter="Include" ItemName="SortedContent"/>

                    </CreateItem>

                    <Message Text="@(SortedContent,',')" />

    </Target>