Install ASP.NET MVC 3 Manually

Update 14-jan-2011: I found the root solution to all my problems with msiinv, check my post on the subject.

I don’t know exactly why but I can’t install the MVC 3 package provided by Web Platform Installer nor the standalone one, so I uncompressed it and tried to figure out how to install it manually.

The problem I have is with vs10-kb2465236-x86.exe that gives me a “failed with 0x8007066a” error. It seems to be for enabling Razor syntax but the prerequisites are Visual Studio 2010 Ultimate ENU. I have Visual Studio 2010 Professional ESN and that may be the reason or may not.

Anyway, I found the way to install the package manually, although the Razor Intellisense stuff is not available in my setup.

First you have to uncompress the AspNetMVC3Setup.exe into a folder and then install the following files (I got the sequence from the parameterinfo.xml file, which describes the installation process):

  • VS10-KB2465236-x86.exe (it fails in my case, I don’t install it)
  • AspNetWebPages.msi – ASP.NET Web Pages
  • AspNetWebPagesVS2010Tools.msi – ASP.NET Web Pages Visual Studio 2010 Tools
  • AspNetMVC3.msi – ASP.NET MVC 3 Runtime
  • AspNetMVC3VS2010Tools.msi – ASP.NET MVC 3 Visual Studio 2010 Tools
  • NuGet.msi – NuGet

And that’s all. In case you have Web Developer Express instead of full Visual Studio, you have ton install the tools specifically for that edition, AspNetWebPagesVWD2010Tools.msi instead of AspNetWebPagesVS2010Tools.msi and AspNetMVC3VWD2010Tools.msi instead of AspNetMVC3VS2010Tools.msi.

Good luck!

Deployment web site Zip with MsBuild and TeamCity

One of the most useful practices that I’ve been using during the last years is continuous integration and for that purpose, TeamCity is the tool of choice, which offers a free professional version with up to 20 users and 20 build configurations, enough for a small team.

Recently I tried (again, first time I found some trouble) to create an MsBuild script to make a web publication to a folder an then zip that folder in order to make a simple distributable with all the things needed to set up our web project that anyone in the organization could download and install, instead of having to create that zip myself or publishing through Visual Studio.

Finally, I got the script and seems to work using MsBuildCommunityTasks and some community knowledge.

The first part deals with publishing the site:

  <PropertyGroup>
    <OutputFolder>$(MSBuildProjectDirectory)\publish</OutputFolder>
    <TempFolder>$(MSBuildProjectDirectory)\temp\</TempFolder>
  </PropertyGroup>
  <Target Name="PublishSite">
    <Message Text="Publishing in folder: $(OutputFolder)" />
    <RemoveDir Directories="$(OutputFolder);$(TempFolder)" ContinueOnError="true" />
    <MSBuild
      Projects="src\Adapting.Web\Adapting.Web.csproj"
      Targets="ResolveReferences;_WPPCopyWebApplication"
      Properties="Configuration=Release;WebProjectOutputDir=$(OutputFolder);OutDir=$(TempFolder)"
      StopOnFirstFailure="true" />
    <RemoveDir Directories="$(TempFolder)" ContinueOnError="true" />
  </Target>

I define some variables and then I call the _WPPCopyWebApplication which is the important target (in .NET 2.0 was _CopyWebApplication). This should be the same as publishing a web site to a folder using the wizard.

Then, I get the files in the OutputFolder and make a zip with them:

  <Target Name="PackageSite" DependsOnTargets="PublishSite">
    <ItemGroup>
      <PublishFiles Include="$(OutputFolder)\**" />
    </ItemGroup>
    <Message Text="Packaging Site" />
    <Zip
      Files="@(PublishFiles)"
      ZipFileName="release-web.zip"
      WorkingDirectory="$(OutputFolder)"
      />
  </Target>

I simplified this a little bit because I have as well a target that generates the build number from SVN and changes the AssemblyInfo.cs and uses this numbers to name the zip.

In TeamCity, you can create a new configuration with *.zip as artifacts, that points to your SCM (Subversion in my case) and the most important thing is that uses the MsBuild runner targeting PackageSite.

The only thing that was that if I put the <ItemGroup> section out of the <Target>, works on the command line but not inside TeamCity.

That’s all, I hope this helps.

Sources:

Testing ConfigurationSection

Creating ConfigurationSections can be tricky but it’s quite straightforward to test them, provided you take care and don’t try to do too much like this subtle bug in MvcContrib.IncludeHandling that lead me crazy for a couple of hours.

The thing is that the code does like this:

public IncludeHandlingSectionHandler()
{
    _types = new Dictionary<IncludeType, IIncludeTypeSettings>
    {
        { IncludeType.Css, Css },
        { IncludeType.Js, Js }
    };
}

Where this is the constructor and .Css and .Js properties are marked with [ConfigurationProperty], so in theory seems correct.

In the tests, there’s an XML file with the section and it’s loaded using the DeserializeSection method of the ConfigurationSection base class. And this seems correct, everything goes ok and the dictionary is populated correctly with the data from the XML file.

But it’s wrong. If you add the section to the app.config (or web.config) file and instead of using DeserializeSection you use ConfigurationManager.GetSection(sectionName), the constructor is called before populating the Css and Js properties so the dictionary is not created properly but as those properties return a default implementation in case there’s no configuration, it seems to work, but the configured values are never loaded.

This way, tests pass but it’s impossible to configure the library via web.config. Anyway, in my opinion the problem is in .NET Framework because internally, GetSection should use DeserializeSection to be consistent.