Tag Archive for 'c#'

Getting Jenkins to publish ASP.Net Web Projects with msbuild on Visual Studio 2010 files

I’m putting this here because there is a lot of google foo out there for this particular issue and none of the answers were from an authorative enough source for me to trust, so I just had to figure it out for myself.

The scenario

We have a Visual Studio Web Application solution that has been continually upgraded in the business for at least the last 7 years. It has been through several architecture changes and Visual Studio project format upgrades up to Visual Studio 2010 and ASP.Net 4. Having started as an original n-tiered architecture we have multiple layers of references/dependencies between projects roughly ordered as such:

  1. Third Party Binary References
  2. DAL layer
  3. Business Logic Layer
  4. Application Settings Transport project
  5. Web Application Application Layer

There is some cross referencing from projects at different layers further down than the one below it (the Web App has to reference some of the Third Party dlls).

We have been publishing the application manually through VS 2010 by rebuilding the whole solution manually using specific Build Configurations and then right-clicking on the web project and using the publishing wizard.

We recently tried to get Jenkins to automatically build and publish (we ended up using package deployment, not publishing) the application using an msbuild task and were unable to get either the transforms, or the correct binary dlls in the publish folder. This was causing us no end of pain.

The multiple causes and fixes

Just finding the correct msbuild command line to get it to work was chore. We ended up settling on:

msbuild $WORKSPACE\Website\Website.sln /v:$MsBuildVerbosity /p:Configuration=$PublishEnvironment /p:Platform="Any CPU" /p:DeployOnBuild=True /p:DeployTarget=Package /p:AutoParameterizationWebConfigConnectionStrings=False /p:AllowedReferenceRelatedFileExtensions=".pdb" /p:ExcludeGeneratedDebugSymbol=false /p:_PackageTempDir="$WORKSPACE\Publish\$PublishEnvironment\Website"

Once we got that right we had to actually do the following to get the correct output published with correct configs:

  1. Move the config transform task into the pre-build section from post-build section
    1. There seems to be a race condition in msbuild between the transforms and the file publish activity. Sometimes they would make it in, sometimes they wouldn’t.
  2. Move any post-build tasks in pre-build.
  3. Update every single non-GACed assembly or project reference to ensure they had the node <Private>True</Private> (this is the xml behind the Copy Local property in the reference properties screen)
    1. This is because VS 2010 sees the absence of the Private attribute as a default of Copy Local = True whereas msbuild sees it’s absence as defaulting to false
    2. This is an absolutely nutso decision from MS. Why on earth would you have the command line build system treat project properties differently than your IDE?
  4. Ensure every single referenced project (or reference project of a referenced project) has a consistent default build Configuration and Platform defined, and then define a solution Configuration that sets the default Project Configs for your release configuration.
    1. This is critical for us because we have an upstream platform branch that is read-only and externaled into the build/reference path for customer projects.
    2. The platform projects only have Debug and Release configurations for Any CPU platforms but the customer projects have build configurations to ensure the config trasnforms are generated (Dev, Test, Staging, Production).
    3. To make this work we had to define these four configurations in the solution file and map them to their corresponding projects in the customer projects but also map them to the Release configuration in the platform projects.

Codex Space Block – Easy access to Azure Blob Storage

So I’ve been doing a little playing around recently with Azure, looking at pushing some of the more processor intensive worker units out into the cloud.

I know there’s been a whole bunch of discussion about whether ‘your data’ belongs out in the cloud and all that, and on that front I’m still undecided, but pushing processor intensive modules that act on small transient blocks of data sounds like the perfect test case for a cloud app. More on what that app is to be later.

In the mean time I was looking to find an easy way to get my files onto my Azure connected account’s blob storage. Enter Codeplex Space Block.


This app supports a whole bunch of cloud storage systems, but added Azure support after it’s major release. This means you need to use the link I posted above to download the latest commit, not the latest stable rellease (

I brought the app down for two reasons, firstly to get my files up onto the blob quickly and secondly to see a non-trivial example of accessing blob storage from C#.

Points to note:

  • In the UI, the Account name is the azure sub-domain you used when creating the blob storage project. In the screenshot above this would have been ninepixels, taken from the URL http://ninepixels.blob.core.windows.net.
  • The UI works very much like an ftp program, so no windows shell integration for drag and drop.

C# for the iPhone

Awesome post from an Aussie no less which is a non-trivial iPhone application using c# on monotouch.

The thing I love about monotouch is that it lets me leverage my .Net Skills (not just c#, but how the .Net run time works) and marries it to the low-level iPhone development infrastructure. The hardest part about getting into iPhone development for me was Objective-C, and now I don’t need to go there.

Points to note:

  • Obviously since interpretation is not allowed on the iPhone the guys at the mono project had to put together monotouch, which statically links the parts of the .net framework needed into each iPhone app.
  • Monotouch is a payed for product.

Microsoft AJAX CDN

Over on ScottGu, this announcement about Microsoft setting up a CDN for ASP.Net Agax and jQuery.

Free for commercial and non-commercial use. A great idea for sites that heavily use jQuery or ASP.Net Ajax.

PHP Toolkit for ADO.Net Data Services

Found this interesting link on this post over on monologue.

Basically it’s a PHP toolkit to get access to the data exposed by ADO.Net Data Services, which exposes data in a RESTful manner.

Managed Port of Sqlite

Over on Miggie’s blog, a post about a line-by-line port of Sqlite to C#.

It obviously takes a performance hit (something like 5 times slower) but think of all the opportunities it opens up. I’m thinking mainly about Windows Phone development using Compact Framework and no longer needing the external Sqlite dll linkage (figuring out which one to use was a nightmare).

Miggie mentions using it in Silverlight apps, which is an awesome idea, or in medium trust ASP.Net servers. The Silverlight use will have to wait till they pull all the P/Invokes out of it, which doesn’t seem to be too far off, as is the possibility for some performance improvements by capitalising on the .Net Framework features instead of being a line-by-line port from C.

Microsoft extends community promise to ECMA C# and CLI

First seen over on monologue, Miguel writes to say that Microsoft has extended it’s Community Promise (around patents etc.) to the ECMA standardised C# and CLI components.

Quote from the announcement by Peter Galli at MS:

It is important to note that, under the Community Promise, anyone can freely implement these specifications with their technology, code, and solutions.You do not need to sign a license agreement, or otherwise communicate to Microsoft how you will implement the specifications.

The Promise applies to developers, distributors, and users of Covered Implementations without regard to the development model that created the implementations, the type of copyright licenses under which it is distributed, or the associated business model.

Under the Community Promise, Microsoft provides assurance that it will not assert its Necessary Claims against anyone who makes, uses, sells, offers for sale, imports, or distributes any Covered Implementation under any type of development or distribution model, including open-source licensing models such as the LGPL or GPL.

Full Community Promise over at Microsoft.

Note: as Miguel says in his post, mono implements a whole bunch of .Net technology above and beyond ECMA C# and CLI and those parts (ASP.Net ADO.Net etc) aren’t currently covered by this promise.

ASP.Net MVC goes MSPL and gets Mono and MonoDevelop support

Been all over the internet, this one, and I’m late to make note of it, but Miguel mentions that the ASP.Net MVC extensions have been released as MSPL and is works in mono, and in fact has MonoDevelop support.

ASP.Net MVC in MonoDevelop

Which equality methods to override and when in C#

A great, relatively brief post over on monologue that oulines which of the equality methods/operators to override when.

Sorting Collections without implementing IComparable

This is an old but a goodie from Albert over on his blog. It uses delegates to allow inline sorting of Generic collections based on the specific types without having implemented IComparable in the type being sorted.