views:

1997

answers:

4

Has anyone got a Web Deployment Project to work with ASP.NET MVC? When I open the "deployed" project, a lot of the files are missing that MVC requires and makes it tough to Publish to the server with all the missing files in the project.

Or... Is there a better way than a Web Deployment Project to modify the Web.Config for MVC apps? I have differences (SMTP and connection strings) that need to be updated before uploading and Web Deployment Projects seem to be the right method.

Thanks as always!

Update: I am missing at least global.asax, global.asax.cs, and default.aspx.cs.

Update 2: Once I Publish, I get this error. Could not load type 'AppNamespace._Default'.

+4  A: 

I haven't set up a Deployment project yet with my mvc app but I've been using this technique outlined by Scott Hanselman and it works great.

Managing Multiple Configuration File Environments

Mike Roosa
Thanks. This worked with some hacking.
Daniel A. White
A: 

I've found it working for me.

When you say there are files missing, are you talking about the System.Web.Mvc files and such? You need to make sure in your web application that these references are set to copy locally.

Steve Sheldon
+1  A: 

The 3 specific files you have listed are all compiled into the binary produced by your ASP.NET MVC web project. Open up your .csproj and you will see:

<Compile Include="Global.asax.cs">
  <DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Default.aspx.cs">
  <DependentUpon>Default.aspx</DependentUpon>
  <SubType>ASPXCodeBehind</SubType>
</Compile>

Open up your binary in a tool such as Reflector and you will see the classes. Therefore you don't need to deploy them.

These MSBuild steps in the MVC .csproj render part of what the Web Deployment Project does (i.e. compiling a single binary for the site) redundant.

As for the token replacement you can either keep your Deployment project or probably copy the relevant MSBuilds steps from your .wdproj file into your .csproj file. This is not something I've done, but am shortly to try myself.

A: 

I have deployt succesfully to IIS6 using a Web Deployment Project. I had issues deploying to Server 2003 first, but in my case it realy was a problem of the stage-environment. I first deployt to a local IIS to check if it was a problem of the build or of the environment. I did not use config - replacement.

This is my build script:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe "D:\Projekte\NiceProjectName\source\NiceProjectName_Build\NiceProjectName_Build.wdproj" /t:Build /p:Configuration=Release

Here is my wdp:

<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.21022</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{E5E14CEB-0BCD-4203-9A5A-34ABA9C717EA}</ProjectGuid>
    <SourceWebPhysicalPath>..\NiceProjectName</SourceWebPhysicalPath>
    <SourceWebProject>{3E632DB6-6DB3-4BD0-8CCA-12DE67165B48}|NiceProjectName\NiceProjectName.csproj</SourceWebProject>
    <SourceWebVirtualPath>/NiceProjectName.csproj</SourceWebVirtualPath>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
    <SingleAssemblyName>NiceProjectName_Build</SingleAssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>false</DebugSymbols>
    <OutputPath>..\..\deploy</OutputPath>
    <EnableUpdateable>false</EnableUpdateable>
    <UseMerge>true</UseMerge>
    <SingleAssemblyName>NiceProjectName</SingleAssemblyName>
  </PropertyGroup>
  <ItemGroup>
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets" />
</Project>
Malcolm Frexner