Rob
Rob

Reputation: 11798

VisualStudio 2012 & MVC4: How to deploy individual files/folders to filesystem?

I'm building a rather complex web application for data visualization with ASP.NET MVC4 in VisualStudio 2012 Professional. For technical reasons (involving realtime server-side messaging etc.) I have to deploy the web app via filesystem to our production server, so I can't use the development server in most cases.

As the project grows and contains more and more scripts, deploying almost takes a minute to complete, even on 1000BASE-T ethernet, which is very annoying. It would be absolutely sufficient in most cases to "update" only specific files or folders from within my project, because most files will usually never change (JQuery and other frameworks for example).

According to this post, it should be possible to publish individual files since Visual Studio 2012.2, but it does not work for me, the described options in the context menu do not exist.

This is the exact version of my VS:

Microsoft Visual Studio Professional 2012
Version 11.0.60315.01 Update 2
Microsoft .NET Framework
Version 4.5.50709

Has anyone faced this issue before? It'd be great to resolve this problem.

Upvotes: 5

Views: 3073

Answers (3)

Grimace of Despair
Grimace of Despair

Reputation: 3506

We got several Web Projects (9.0) that we develop with VS2010. We use TeamCity for production deployment as follows:

  1. Normal development happens with Debug build

  2. Release build is configured to use MSDeploy with the following properties (these can be either set in the csproj file or in the TeamCity environment variables):

    • DeployOnBuild: true
    • DeployIisAppPath: sitename.in.iis
    • MSDeployPublishMethod: MSDeploy
    • CreatePackageOnPublish: true
    • PackageLocation: AbsoluteOrRelativeLocation\Package.zip
    • SkipExtraFilesOnServer: true (optional)
    • IncludeSetAclProviderOnDestination: false (optional, if true, can take a long time when deploying)
    • PublishDatabases: false (optional)
    • ExcludeGeneratedDebugSymbol: true (optional)
    • *ExcludeApp_Data*: true (optional)
  3. TeamCity automatically uploads the built package to our production server with FTP, but you could as well just copy it somewhere.

  4. On the deployment location, you can invoke the cmd that's outputted together with the package. You can also pass some flags, like:

    Package.Deploy.cmd /y -enableRule:DoNotDeleteRule

This last step is a pretty efficient, because it only updates files that were changed.

I'm not sure whether in your case, you'd need to put the whole package on the production server before updating, or whether you can tweak the Package.Deploy.cmd to do that from the build location.

Upvotes: 0

Andreas
Andreas

Reputation: 2242

For some reasons this feature described in the blog post, you mentioned, works only for Publish method "Web Deploy". I use this feature in my current MVC application and I noticed that if I switch to "File system" the described options in the context menu disappear.

Upvotes: 4

Kate Paulk
Kate Paulk

Reputation: 383

Further down the comments on the link you gave (http://www.west-wind.com/weblog/posts/2013/May/10/Publish-Individual-Files-to-your-Server-in-Visual-Studio-20122#127707) there is a note that you must have configured and saved your publish settings before the option will be present.

I can verify that a project I have never published does not have the option to publish individual files. One that I have published does have that option.

Upvotes: 2

Related Questions