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'.
In Visual Studio, on the File menu, select New Project, and then select the ASP.NET Web Application template. Click OK. Visual Studio opens to the Source view of the Default. aspx page so that you can edit it.
In Solution Explorer, right-click on the project and click Publish. Visual Studio can create a new App Service resource, but this update will be published over the existing deployment. In the Pick a publish target dialog, select App Service from the list on the left, and then select Select Existing. Click Publish.
The simple answers are as follows: New Web Site - creates code behind pages that are compiled at the server when page is requested. New Web Project - creates pre-compiled pages into one or more assemblies (entire site even), and deployed on server.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With