December 2009 - Posts

CruiseControl.NET Configuration Reference

For some reason it is very difficult for me to find the CruiseControl.NET configuration reference online.  Most of the time I end up on an older reference which is out of date and just not correct. 

This is the CruiseControl.NET reference that appears to be up-to-date:

CruiseControl.NET Configuration Reference 
http://confluence.public.thoughtworks.org/display/CCNET/The+CruiseControl+Configuration+Block

On the bottom of each page is a list of the children for each configuration block and at the top is the breadcrumb for how far you have drilled down into the tree.

image

image

And then you can view the full CruiseControl.NET configuration hierarchy here.

This blog post is mostly for me but also, if I am having a tough time finding the reference then I imagine a lot of other people are too.



Prevent CruiseControl.NET error “Source control operation failed: Working copy locked svn”

My CruiseControl.NET build system was running into an error whenever two projects were trying to build at the same time.  Both of these projects try to go out to our subversion source control repository and one will win and the other gets locked out.

The build will then fail with this type of error:

ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control operation failed: svn: Working copy 'XXXX' locked svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details) .

To get around this issue you can use the “queue” attribute of the project node:

image

Here is the Thoughtworks CruiseControl.NET Project configuration reference section: http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block

Originally I did not set a queue value for each project that is built.  The default in this instance is the project name, so each project ends up in its own queue and therefore they will build as soon as possible and cause the locking error.

From the Thoughtworks reference:

queue 
The name of the integration queue that this project will use. By default, each project runs in its own queue. (Added in CCNet 1.3) 

So by setting the queue for each of the projects to the same value (since all of the projects are related), each of them will wait and build one at a time, resolving the “Source control operation failed: svn: Working copy 'XXXX' locked svn” error.

Note: You can also set the queuePriority to indicate the order the project should build when it is in the queue.

This StackOverflow post lead me to this solution: How can I prevent concurrent builds in CruiseControl.NET?



Handle the button click event from an ASP.NET ListView control

Here is how you can handle the event of a button from within an ASP.NET ListView control.

Add your button to the ListView Template like you would any other control:

<asp:ListView ItemPlaceholderID="Test" runat="server" ID="ListView1" >
    <ItemTemplate>
        <asp:Button runat="server" Text='<%# Eval("MyProperty") %>' CommandArgument='<%# Eval("MyProperty") %>' /><br />
    </ItemTemplate>
</asp:ListView>

image

And then handle the ListView.ItemCommand event in your code:

image

That is really all there is to it.  The ListView will bubble up the Button’s click event to the ListView_ItemCommand event handler and then you can handle it there.  You can also use the CommandArgument property to send button specific data, such as the particular ID of the row or item that the user clicked the button for.

This call also be used on some of the other databound controls such as the ASP.NET Repeater.

 

Full Example Code:

ListViewButtonExample.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ListViewButtonExample.aspx.cs" Inherits="ListViewButtonExample" %>
<html>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ListView ItemPlaceholderID="Test" runat="server" ID="ListView1" >
            <LayoutTemplate>
                <asp:Literal runat="server" ID="Test"></asp:Literal>
            </LayoutTemplate>
            <ItemTemplate>
                <asp:Literal runat="server" Text='<%# Eval("MyProperty") %>'></asp:Literal>
                <asp:Button runat="server" Text='<%# Eval("MyProperty") %>' CommandArgument='<%# Eval("MyProperty") %>' /><br />
            </ItemTemplate>
        </asp:ListView>
        <asp:Literal runat="server" ID="Literal1"></asp:Literal>
    </div>
    </form>
</body>
</html>

ListViewButtonExample.aspx.cs:
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;

public class MyObject
{
    public String MyProperty { get; set; }
}
public partial class ListViewButtonExample : System.Web.UI.Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        ListView1.ItemCommand += new EventHandler<ListViewCommandEventArgs>(ListView1_ItemCommand);
    }

    void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        Literal1.Text = "You clicked the " + (String)e.CommandArgument + " button";
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            List<MyObject> col = new List<MyObject>();
            col.Add(new MyObject { MyProperty = "test 1" });
            col.Add(new MyObject { MyProperty = "test 2" });
            ListView1.DataSource = col;
            ListView1.DataBind();
        }
    }
}

 

Technorati Tags: ,


IIS7 Search Engine Optimization Toolkit does not like HTML5 Doctype

The IIS7 Search Engine Optimization (SEO) Toolkit is an awesome tool to review your site and indicate any problems with the html that may cause search engines not to index your website properly.  Check out Scott Guthrie’s post on the IIS7 Search Engine Optimization Toolkit or you can download it from the IIS website at the tool’s home: IIS7 SEO Toolkit.

But I ran into an issue with the tool the other day where it was not returning the proper results.  I ran it against a website I was working on and it only crawled one page and returned results that were just not correct:

image

The errors: “The title is missing.”, “The description is missing.”, and “The <h1> tag is missing.” were incorrect since I had all of those on the home page of the site I was testing, but also it was curious that it was not crawling any other urls off of that home page.

AND the content tab even showed all of these things in the html that the tool had retrieved:

image

Eventually I was able to track it down to using the HTML5 Doctype tag:

<!DOCTYPE html>

The HTML5 document type is not official yet but I have gone ahead and started using as recommended by many developers but apparently the IIS7 SEO Toolkit does not like this doctype yet.  Temporarily I switched it to another doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

And the SEO Toolkit worked as expected.  Just a heads up for any other developers that run into this when using HTML5 DOCTYPE.

UPDATE (2009-12-07):

Dave Cox added a comment about it not being the HTML5 DOCTYPE per say but the whitespace that comes before it.  Having a line of whitespace AND the HTML5 DOCTYPE causes the IIS7 SEO Toolkit not to read the content correctly.

Bad:
image

Good:
image

I am using ASP.NET MVC in this project so that means my master page will look like this; the DOCTYPE declaration on the same line as the Master page directive:

image



More Posts « Previous page

Search

Go

This Blog

News

Syndication