Lobstrosity
Lobstrosity

Reputation: 3936

Visual Studio 2012 One-Click Publish Publishes All Files (Not Just Updates)

According to the documentation for One-Click Publishing in Visual Studio,

The first time you publish, all of the files that are required to run your application are copied to the hosting provider. When you publish updates, only changed files are copied.

In our environment (ASP.NET MVC 4 in Visual Studio 2012, in case it matters), if I am the first to publish a web application, all files are published. If I make updates and then publish again, only the updates get published.

So far, so good.

However, if another developer then publishes, all files (including unchanged ones) are published. They can make updates and publish, and only the changes are published. But then if I publish again, all files (including unchanged ones) are published.

Basically, whenever the project is published by someone other than the most recent person that published, all files (including unchanged ones) are published.

  1. Is this behavior intentional for some reason?
  2. Is there any way to prevent it (so that only updates are published, regardless of who is publishing)?

Upvotes: 2

Views: 222

Answers (1)

Lobstrosity
Lobstrosity

Reputation: 3936

A Twitter exchange with Sayed led me to a blog post of his that documents a way to fix the issue in Visual Studio 2012 and up (no support for 2010, sadly).

The default method of determining which files the publish process will upload uses file timestamps, which, for whatever reason, leads to the issue we were seeing.

There's an alternative method that uses checksums instead of timestamps. To use the checksum method, include the following property group in your .csproj file anywhere above the Microsoft.WebApplication.targets import:

<PropertyGroup>
    <MSDeployUseChecksum>true</MSDeployUseChecksum>
</PropertyGroup>

There's a brief delay while it calculates and compares checksums, but it's much faster than waiting for all files to be published.

Upvotes: 1

Related Questions