1

I have a Windows Azure Website and I've setup Azure Continuous Integration with hosted Team Foundation Server. I make a change on my local copy, commit to TFS, and it gets published to Azure. This is great, the problem is that I have an Access database in the ~\App_Data\ folder and when I check-in the copy on Azure gets overwritten.

I setup a web-deploy publish profile to "Exclude App_Data" and configured the build task to use the web-deploy profile, and now it DELETES my ~\App_Data\ folder.

Is there a way to configure Azure Continuous Integration to deploy everything and leave the App_Data alone?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Nate
  • 30,286
  • 23
  • 113
  • 184
  • 1
    It sounds like you could use a 'skip rule', though I've not tried to do it with Azure yet. You may find these links useful: http://stackoverflow.com/questions/4289440/make-msdeploy-visual-studio-not-delete-app-data-folder-but-delete-everything-e and http://stackoverflow.com/questions/12576662/msdeploy-skip-rules-when-using-msbuild-publishprofile-with-visual-studio-2012 and http://blog.richardszalay.com/2012/12/18/demystifying-msdeploy-skip-rules/ – Jason Haley Apr 23 '13 at 00:29
  • @JasonHaley As noted, I have setup the web deploy to skip the App_Data folder, but the problem is that after publishing I have NO App_Data folder, not the one that was there before, and not the one that was in my source control. Its just gone. This is a major pain, and I'm hoping I'm just doing something wrong, but I can't seem to figure out what it is. – Nate Jun 05 '13 at 22:22

1 Answers1

0

I use the 'Publish Web' tool within Visual Studio, but I think the principles are the same:

  • if you modify a file locally and publish, it will overwrite whatever's on the web
  • if you have no file locally - but the file exists on the web - it will still exist on the web after publishing

The App_Data folder gets no special treatment in this behaviour by default. Which makes sense - if you modified an .aspx or .jpg file locally, you would want the latest version to go on the web, right?

I also use App_Data to store some files which I want the web server (ASP.NET code) to modify and have it stay current on the web.

The solution is to:

  1. Allow the web publishing to upload App_Data, no exclusions.
  2. Don't store files in App_Data (locally) that you want to modify on the web.
  3. Let the web server be in charge of creating and modifying the files exclusively.

Ideally you would not have to change any code and the server can create a blank file if necessary to get started.

However if you must start off with some content, say, a new blank .mdf file, you could do the following:

  1. Locally/in source repository, create App_Data/blank.mdf (this is going to be a starting point, not the working file).
  2. In Global.asax, modify "Application_Start" to create the real working .mdf file from the blank starting file:

    // If the real file doesn't exist yet (first run),
    // then create it using a copy of the placeholder.
    // If it exists then we re-use the existing file.
    string real_file = HttpContext.Current.Server.MapPath("~/App_Data/working.mdf");
    if (!File.Exists(real_file))
        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/blank.mdf"), real_file);
    
Yoshi
  • 3,325
  • 1
  • 19
  • 24