Using VS 2008 Deployment Projects with ASP.NET MVC

Has anyone gotten a web deployment project for working with ASP.NET MVC? When I open a “deployed” project, many files are missing, which requires MVC, and makes it difficult to publish all the missing files to the server on the server.

Or ... Is there a better way than a web deployment project to modify Web.Config for MVC applications? I have differences (SMTP and connection strings) that need to be updated before the download and web deployment projects look right.

Thanks, as always!

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

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

+6
asp.net-mvc web-deployment-project
source share
4 answers

I have not created a deployment project with my mvc application yet, but I used this method described by Scott Hanselman and it works great.

Manage environments with multiple configuration files

+5
source share

The 3 specific files you specified are all compiled into a binary file created by an ASP.NET MVC web project. Open 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 your binary in a tool like Reflector and you will see the classes. Therefore, you do not need to deploy them.

These MSBuild steps in MVC.csproj display part of what the web deployment project does (i.e., compiles a single binary for the site).

As for replacing the token, you can either save the Deployment project, or perhaps copy the appropriate MSBuilds steps from your .wdproj file to your .csproj file. This is not what I did, but I will try it soon.

+1
source share

I found this to work for me.

When you say files are missing, are you talking about System.Web.Mvc files, etc.? You must ensure that in your web application these links are configured to be copied locally.

0
source share

I have successfully deployed to IIS6 using the Web Deployment Project. At first I had problems deploying to Server 2003, but in my case it was a stage environment problem. First I deployed local IIS to check if there was a build or environment problem. I did not use configuration 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"> <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> 
0
source share

All Articles