Search code examples
c#visual-studio-2008.net-3.5msbuildweb-deployment-project

Do Web Deployment Projects work with x86 build configuration


I have a need to build a website and several DLLs that it references in an x86 configuration. To date we have been using Web Deployment Projects to create Zip files of the resultant site and all it's required files. We need to continue to use WDPs however, they seem to have problems with the x86 build configuration.

In my project, when I build the solution in Release/x86 I get the following error.

           Description                              File                           Line   Column   Project
Error  80  Could not load type 'WwwRooot.Default'.  /WwwRooot.csproj/Default.aspx  1      1        WwwRooot.csproj_deploy

There are no build errors or warnings from the web application or any of the referenced class libraries.

I thought this might be something specific to the project I'm working on so to prove myself wrong I created a solution containing a Web Application (c#). I then used the Configuration Manager to create the x86 configuration by copying the Any CPU config. I checked the properties page an made sure the new config was set to build to x86, and it was. I built the solution without error.

Next I right clicked the Web App and added a WDP from the context menu. Right clicked on the WDP and edited the project file. At this point I changed any references for AnyCPU to x86 so that the WDP has conditions of x86 build. I rebuilt the solution in Release/x86 and everything builds fine.

Next I add a Class Library, use Configuration Manager to create an x86 config for this library, add a reference to the web app for the library and then rebuild all in Release/x86 and I receive the same error as detailed above.

Are WDPs compatible with x86 build?

If I remove the Class Library (and the reference) the solution (including the WDP) builds fine.

I am using Visual Studio 2008 SP1, with the appropriate WDPs installed, on 64Bit Windows 7 Pro.


Solution

  • Out of the box, Web Deployment Projects (WDP) don't work with x86 or x64 build configurations. This is because a Web Application built under one of these configurations outputs the resultant assemblies in a different place and the WDP doesn't know to look there for the DLLs.

    There are a few things you'll need to do to get the WDP working with your x86 configuration.

    Firstly, your WDP probably doesn't have an x86 configuration, you'll need to create one. Edit the deployment project using the XML editor in Visual Studio (or any text editor), near the top of the file will see a <propertyGroup> tag (usually the second one) with a condition Debug|AnyCPU like so:

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <OutputPath>.\Debug</OutputPath>
        <EnableUpdateable>true</EnableUpdateable>
        <UseMerge>true</UseMerge>
      </PropertyGroup>
    

    Duplicate this whole tag and change the configuration to be Debug|x84:

      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
        <DebugSymbols>true</DebugSymbols>
        <OutputPath>.\Debug</OutputPath>
        <EnableUpdateable>true</EnableUpdateable>
        <UseMerge>true</UseMerge>
      </PropertyGroup>
    

    Now save the file and open the configuration manager (Build menu > Configuration manager) and check your deployment project now has an x86 configuration.

    Now edit the Web Application Project file using your text editor and locate the outputPath element within the Debug|x86 configuration. It should have a value of Bin\x86\Debug. This needs changing to Bin:

     <!-- Before -->
     <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
        <OutputPath>Bin\x86\Debug\</OutputPath>
    
     <!-- After -->
     <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
        <OutputPath>Bin\</OutputPath>
    

    Save, close and reload you Web Application Project. We've now instructed the Web Application to put it's DLLs where the WDP expects to find them.

    Set your build configuration to x86 and build the project.

    Rinse and repeat for Release and any other build configurations you might have.