visual-studiogoogle-compute-enginegoogle-cloud-visualstudio

Publish to Google Cloud Compute Engine via Visual Studio - Deleting Live Files


I've got a project I'm deploying in Visual Studio 2015 to Google Compute Engine via Google Cloud Tools for Visual Studio.

It all works pretty well apart from one thing:

I have an uploaded assets folder on the 'live' site. this contains images uploaded via the site online. My local copy in VS doesn't have all these assets but the folder structure is mirrored.

The Problem

When I publish, some of the files in the uploaded assets folder get removed on the live site.

I want the Publish action to ignore this folder as the live server version of it should remain untouched. Can I do this??


Solution

  • As of Google Cloud Tools for Visual Studio version 1.4.0, no, there is no good way to do this. The extension is calling MSDeploy with a set of hard coded arguments.

    The workaround I would suggest is to use an MSBuild publish profile.

    Before creating the profile, you will need the public IP of your GCE VM, and a username and password setup for that VM. You can get these from the Google Cloud Explorer. The public IP is in the properties of the VM, and you can get a username and password from "Manage Windows Credentials..." in the context menu of the VM.

    Now to create the profile. Right click your project, and select "Publish...". Choose "IIS, FTP, etc" and push "Create Profile". Use the public IP of your VM as the server, and the username and password you got earlier.

    With the publish profile created, you can use this answer to ignore your desired directory.

    The drawback to this solution is you will need to update the target IP when your VM's public IP changes.

    P.S. The next version of Google Cloud Tools for Visual Studio will be calling MSBuild, rather than MSDeploy directly, so you will be able to ignore the folder by changing your build file.