Contact   •   Products   •   Search

Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs

Publish Individual Files to your Server in Visual Studio 2012.2


In Visual Studio 2012 Update 2 there's a sweet little new gem, that I championed for some time in the past, and that has finally made it into the VS box: You can now publish individual files to the server without having to publish the entire site. You can now publish 1 or more files simply by selecting them in the Solution Explorer and using the Context Menu's Publish Selected Files or Publish File xxxx.xxx.

PublishIndividualFile

In the past if you wanted to publish your site, it was an all or nothing affair: You basically had to rebuild and re-publish the entire site. Publishing works great when you're making major updates that affect binaries and configuration settings. In that case you do want a full publish to push up your binary file changes as well as web.config transformations etc. This is a great feature and the cornerstone of publishing which is as it should be.

But on more than a few occasions I've:

  • Forgotten to include some content file like an image in a full publish
  • Had to make a really minor change to a content file or image and need to push it up
  • Make some quick iterative changes repeatedly to a file to tweak the UI or an image on the server

Now, with Update 2 you have another option to publishing the entire site -you can now publish an individual file.

I know this is a minor thing, but I can't tell you how often I use this for quick image or CSS updates. Sometimes I actually prefer making changes to these sorts of things on a live site rather than firing up the local copy first especially if the live site is running with a full set of data. It's often convenient to just push individual files. This is especially true for my personal content sites, more so than typical business applications.

 

Web Deploy Getting Easier

As a side note I've been a big fan of Web Deployment in Visual Studio - it's such a tremendous time saver over manually uploading files to the server and trying to figure out what needs updating. Prior to Web Deploy features in Visual Studio I actually had used a custom solution I cobbled together using FTP that provided much of the same functinality including the abililty to push individual files which I found very useful.

It's also great in a team environment, since publish settings are typically shared in source control. This ensures that everybody is pushing up code consistently to the staging or live server using the same settings that are configured only once. It's great when a new developer comes on board especially - they don't have to configure anything they are just ready to go.

When Web Publishing was introduced the intial versions were horrible to the point of unusability. In VS 2010 it improved somewhat, but the server side installation of Web Deploy was still a major pain in the ass. Getting Web Deploy configured properly on the server has been a real pain in the ass with 3 different installs required and several manual configuration steps.

With the latest Web Deploy 3.0 release though, Microsoft finally seems to have gotten Web Deploy right to where it's a single simple installation on the server that just works once installed. There no longer are any finicky configuration settings and it just works off the single install. Inside of the Visual Studio 2012 Web Publish client also has made the Publish Settings dialog a bit more user friendly and more flexible in what you can use to connect to the server. VS now understands pure site urls and virtuals as opposed to the base site url and Site ID/Name that was required previously and was always confusing.

WebPublishSettingsDialog

The end effect is I no longer dread setting up Web Deploy for the first time on a server, nor do I have to go look up the configuration for another site to figure out what put in the boxes :-).

It's kind of sad that it took so long for Web Deploy to get it all right, but now the whole thing is ridiculously smooth. There are a still a few issues with web.config transforms that are difficult to deal with from time to time, but that's not really Web Deploy's problem, but a problem of how to partition developer specific settings in configuration files which is always a problem.

In any case, I hope some of you find the new single file or selected file publishing feature as useful as I have. It's just one more little tweak that makes life easier and shaves a few minutes off the development process. Score!

Make Donation
Posted in ASP.NET  Visual Studio  


Feedback for this Post

 
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Bryan May 10, 2013 @ 11:11am
I just wish more hosting companies supported Web Deploy. Since it's an extra installation instead of something that can just be turned on by checking a check box in a site's IIS configuration (or a web.config option) many of the smaller, more economical hosts do not support it.
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rick Strahl May 10, 2013 @ 12:55pm
@Bryan - I hear you, but I suppose you can always ask to get it installed - that's worked for me in the past. With Web Deploy 3.0 the install is painless and easy for a server now, which I think was a problem previously.

In fact I remember about 2 years ago I was working on a project where we needed to install Web Deploy and it simply didn't seem to work. It was pretty embarrassing :-) We ended up using the FTP deploy which worked but is quite a bit slower. Same location though was able to install Web Deploy 3 last year no issues, so there are definite improvements there.

FWIW, you can still use the publishing features with FTP for those hosts that don't support Web Deploy. It works great too, although in my experience it is a bit slower than Web Deploy.
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by David May 10, 2013 @ 5:14pm
Hm, for some reason this option is not showing up for me.

I'm on VS2012.2, and I'm using a website (not a web project). I have set up the publish option on the actual site, and that seems to be ok. However, if I right click any files in the web site, I don't get the option to upload.

Any clue if this is restricted to just web projects?
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Michael Lang May 13, 2013 @ 8:06am
David,

I have an MVC4 project that it works on, and a Web API project that it does not work on. I have not setup a publish profile for the Web API project yet, but the MVC4 application does publish to Azure. So I presume the menu option requires knowing how to deploy to the target server, which must have Web Deploy 3.0.

Can you setup your Web site project to deploy to Azure, then verify if the menu option works or not. Azure does support Web Deploy 3.0, as that is what I use for my MVC4 web application.
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rick Strahl May 13, 2013 @ 12:01pm
@David - This all makes sense. I believe you have to have your publish settings configured before you see the individual options since those options do not prompt for profile or settings - they use the current publish profile. So that would explain why you don't see it for the WebAPI project - yet.

The target server does NOT have to have Web Deploy installed to work. You can also use FTP and direct file tranfer (via UNC or network share).
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Steven Carnes May 14, 2013 @ 9:37am
I am on a MVC4 Application, with File System deployment set up and I still do not have the option. Any clue why?
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rick Strahl May 14, 2013 @ 11:51am
@Steven - does a full Publish operation work?
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by David May 15, 2013 @ 1:13pm
Thanks for the responses.

I setup the deploy profile first, but still didn't see the new option.

After poking around a bit more I found this line in the changelog for the update:

"Selective publish – for one or more files you can perform the following actions (after publishing to a Web Deploy endpoint)"

Source - http://www.asp.net/vnext/overview/latest/aspnet-and-web-tools-20122-release-notes-rtw#_Web_Publishing

This makes it sound like it perhaps won't work with an FTP endpoint (which is what I'm using)? Rick, you said it should work with FTP/File transfer though? Have you had this work on your end of things?
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Pawel May 24, 2013 @ 3:24am
Is that is supposed to work with VS 2012 For Web? I've installed update but unfortunately there are any changes (I deploy via FTP)
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rick Strahl May 27, 2013 @ 7:42pm
I've confirmed that the individual publish features work for Web Site projects even without doing an initial publish. I simply opened a folder site, configured publish and exited out the publish dialog and saved. Then simply right click and Publish individual file without a problem. Sweet!
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by drzaus June 14, 2013 @ 8:09pm
So like comment (http://www.west-wind.com/weblog/posts/2013/May/10/Publish-Individual-Files-to-your-Server-in-Visual-Studio-20122#129723) I can confirm that it does not work for FTP publishing; however if I create both an FTP and a Web Deploy publish profile I do get the menu options for "publish selected file" as soon as I create (save, not execute, as @Rick said) the Web Deploy profile. The context-menu options remain after switching, but the actual publish operation hangs at 0%. I can successfully publish the entire site using the FTP profile.
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Justin July 08, 2013 @ 7:41am
I'm using FTP to upload a PHP site. I had been using the VS.PHP plugin which gave a deploy option for selected files in the Solution explorer, but it has other issues. I am now trying out the PHPTools plugin and it allows me to publish the entire site only. Unfortuantely, as you pointed out here, there are times when I need to make a minor change in the middle of a large change. I do not want to publish the entire site at these times, but I's also rather not open an external FTP program to only copy the files I want to update.

I can use the Open Files Filter so I know which of the changed files I want to upload, but then having to go and find them in another program and make sure that I got them all introduces a lot of ebcak risk.

Is there any way to deploy single files over FTP within VS2012?
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rick Strahl July 08, 2013 @ 11:09am
@Justin - no unfortunately for now Individual File Publish is limited to WebDeploy...
# re: Publish Individual Files to your Server in Visual Studio 2012.2
by Rob Gaudet August 29, 2014 @ 7:56am
Wow, yes, individual file publish is an awesome feature. As is the ability to publish the project from VS. MS please keep making mundane tasks easier on developers!
 


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2014