Archive for the 'msbuild' Category

Web Deployment Projects in Visual Studio 2008

Friday, November 30th, 2007

The new release for Visual Studio has been out for MSDN subscribers for a couple of weeks now and if you have tried it out you may have discovered that the Web Deployment Projects are only registered to work with Visual Studio 2005 despite interest in having this capability added directly to the IDE. Instead the add-in will be updated and released for Visual Studio 2008. Today as I upgraded a set or projects from .NET 2.0 to .NET 3.5 I found that the Web Deployment project that I have set up for the website was not loaded, however, I am still able to make use of the project even if Visual Studio does not know what to do with it.

I am a big fan of automation and what MSBuild can do for you. There are bits and pieces of MSBuild sprinkled all over .NET projects. Most project files are actually MSBuild scripts that you can use like any other MSBuild script. What I like to do is place an MSBuild script called build.proj in the root folder of a Solution that I use to carry out common tasks such as building and packaging the Solution. One of these tasks has been to run the Build target in the Web Deployment project for a website and then package the contents of the output folder in a zip file. I prefer doing deployments this way instead of using the publishing feature in Visual Studio which seems to take longer most of the time. Using the MSBuild script also allows me to run the build without using Visual Studio, such as when the code is on a server and not on a development machine. Once the zip file is created I can simply upload it to the server, unzip it and place the files in the directory where IIS is configured to serve up the website. For important websites I make sure to keep an older zip file around in case I need to roll back the changes.

(more...)

Tidy up your Markup in .NET

Monday, November 19th, 2007

Clean markup is important. If you allow a page to include sloppy markup it will switch from rendering in "Standards Compliance Mode" to "Quirks Mode" which will apply different rules to how the layout and style works. It makes for an unpredictable result and can be a major headache. One way to introduce sloppy markup into a website is making use of rich editors that spit out HTML, such as the ASP.NET Rich Text Editor Control on CodePlex. There are others like the RichTextBox, FreeTextBox and FckEditor. Each of these editors are ASP.NET controls while you can get a purely JavaScript solution using TinyMCE which is used in BlogEngine.NET. Some of these solutions do create decent markup, but in the case of the ASP.NET Rich Editor Control, it still creates HTML 3.2 instead of XHTML 1.0 Transitional which has become the de facto standard since ASP.NET 2.0. (XHTML?) It still includes FONT tags and other older syntax which has been deprecated. This is where Tidy comes in.

(more...)

Packer for .NET 3.0.2 Released

Sunday, August 26th, 2007

Packer for .NET has been updated to include an MSBuild Task in addition to the command-line functionality. See the documentation site to learn how to use the MSBuild Task.

Also, Scott Hanselman has released his tools listing and this year it includes a link to Packer for .NET. I am glad he and others have found it useful. The new MSBuild Task should make it even easier to integrate with your build process.

SubSonic and Automation with MSBuild

Sunday, June 10th, 2007

SubSonic is a very useful project that you can use to generate a data access layer by reading your database schema. The command-line utility called SubCommander can generate the code in C# or VB.NET. The command-line tool can also generate scripts for the database to help you with versioning.

These commands can take a few parameters which may be different from project to project. To make it easy to keep track of multiple projects you can use MSBuild to automate the SubSonic tasks. I have prepared a sample project and video to walk through how it works. And if you are new to MSBuild, you can read 7 Steps to MSBuild to get a jump start.

ReSharper Potential and Shortcomings

Monday, June 4th, 2007

I have been reading Oren Eini's blog Ayende @ Rahien (great blog, by the way) and he recently mentioned a bug ReSharper that he wants resolved. The product has several bugs which irks me as well. It has such great potential but in so many ways it has been so disappointing.

For example, at one point it started including support for MSBuild. The features looked impressive and since I spend a lot of time working with MSBuild scripts I was interested in leveraging the new features. I use the MSBuild Community Tasks which is a collection of custom tasks that provide functionality which is not included with the standard tasks. One of the tasks is Zip. When I import these custom tasks and reference the Zip task I see an invalid error message because ReSharper ignores the Import directive.

(more...)

Running MSBuild from Visual Studio

Thursday, May 31st, 2007

I make use of MSBuild on every project I develop. (see 7 Steps to MSBuild) What I have always wanted to do is run MSBuild from within Visual Studio like you can do with Ant scripts in the popular Java IDEs. MSBuild comes with the .NET 2.0 runtime and is a Microsoft utility yet there really are no tools to do what I want. But today I had an idea of adding MSBuild as an External Tool.

(more...)

Post Build Deployments with MSBuild

Thursday, April 26th, 2007
7 Steps to MSBuild

MSBuild is a powerful tool for automation but as the name implies, it is a tool primarily for compiling code. Beyond the initial build MSBuild can also be used in preparation for deployments. To assist with the deployment of websites Microsoft produced Web Deployment Projects which carry out a series of tasks to build a website with the option to replace configuration sections which is a very useful feature. Once I have compiled a project I have multiple deployment targets so I wanted to just reconfigure a project in preparation for a deployment and I found a good way get this done outside of a web deployment project.

Replacing configuration sections is handled by the ReplaceConfigSections task which can be accessed in the Microsoft.WebDeployment.Tasks.dll assembly. You just have to pull it into your own script with the UsingTask directive which is shown in the example script.

(more...)

7 Steps to MSBuild

Thursday, November 30th, 2006

I just put together a tutorial covering MSBuild. I have used MSBuild to automate many .NET projects over the past year and I have picked up a few good techniques which really cut down on all of the work to build, test, package and deploy a project.


  1. Basics
  2. Item Groups
  3. Dependencies
  4. Configurations
  5. Web Deployments
  6. Unit Tests
  7. Packaging

MSBuild: Packaging (7 of 7)

Thursday, November 30th, 2006

When the projects has been built and tested it is helpful to place it into a single package to be deployed. For a website a zip file is sufficient. For another type of application a MSI installer is appropriate. Both packages will be covered here.

(more…)

MSBuild: Unit Tests (6 of 7)

Thursday, November 30th, 2006

Unit testing has caught as a part of the agile methodologies the past several years. It acts as a second line of defense against problems in a deployed environment with the first line being a successful compilation. For a few years now .NET developers have used NUnit to produce unit tests. It is a clone of the JUnit framework which was created for Java development.

Alongside your projects you can place a set of classes which carry specially marked classes and methods and validate that the compiled code conforms to the project requirements. In doing so, you can have the automated build ensure that a new enhancement or bug fix does not cause an unwanted side effect which breaks compliance. And these tests should be run early and often. The sooner you can discover an error the easier it will be to identify the change which caused it. The use of unit tests speed up the development process and also allow the development team to confidently make changes which may otherwise be considered too risky.

(more...)