Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:56:11+00:00 2026-05-28T07:56:11+00:00

I have an application setup with the following Package/Publish Web settings: Only files needed

  • 0

I have an application setup with the following Package/Publish Web settings:

  • Only files needed to run this application
  • (unchecked) Exclude generated debug symbols
  • (checked) Exclude files from the App_Data folder
  • (checked) Include all databases configured in Package/Publish SQL tab – note I do not have any databases configured
  • (unchecked) include IIS settings as configured in IIS Express

In the project, I have an App_Data folder setup, primarily to handle application logs.

The behavior I’d like to see (and expect) is the following:

  1. On initial deploy to a brand new server, the application is copied and an App_Data folder is created with write permissions assigned for the application.
  2. On subsequent deployments, the App_Data folder is ignored because it already exists and the “Exclude files from the App_Data folder” is checked.

However, msdeploy does not appear to do step #1 (step 2 is fine if I create the folder manually). I’ve been unable to find any documentation on the web besides this unanswered so question that seems to confirm the behavior I see.

How do I get msdeploy to create App_Data and assign permissions on initial deployment in this scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:56:12+00:00Added an answer on May 28, 2026 at 7:56 am

    Getting App_Data deployed when starting from scratch

    @tdykstra got this part right. To get App_Data out there (and ACLs set automatically), I did the following:

    1. Adding a placeholder file in App_Data
    2. Set the build action to content on the placeholder (my placeholder file has text in it to let people stumbling across it know why it’s there).
    3. Unchecked “Exclude files from the App_Data folder” on the Package/Publish Web tab of the project properties in VS 2010

    This gets my App_Data folder created and ready for use on the server. However, it will result in all my files getting deleted whenever I republish. This is problem #2 in my question above, and pretty closely resembles this other SO question/answer.

    Preventing data on the server from being deleted on subsequent publish events

    There are two mechanisms in MsDeploy that can get confused (at least I confused them):

    1. Excluding files
    2. MsDeploy skip rules

    These can both be used to solve the problem, depending on the scenario:

    1. @tdykstra’s solution will likely work if you:
      1. Know the names of the files in App_Data in advance (e.g. a sqllite database)
      2. Have the files included in the App_Data folder in your project
    2. The use MsDeploy skip rules to tell MsDeploy to completely skip all deletes on the server for that directory and files in that directory. This solves the problem in all cases, but is much more involved.

    Implementing MsDeploy skip rules

    To implement skip rules you’ll have to abandon the right-click, Deploy option in VS 2010 in favor of right-click, Package, go into a command line, re-jigger a batch file and run a command line). If you’re willing to put up with this experience (I am, because I’m automating it all through a CI process), here are the details:

    1. Edit the project file and add the following. Note that the AbsolutePath argument is a regular expression, so you can get way fancy:

      <Target Name="AddCustomSkipRules">
          <ItemGroup>
            <MsDeploySkipRules Include="SkipDeleteAppData">
              <SkipAction>Delete</SkipAction>
              <ObjectName>filePath</ObjectName>
              <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
              <XPath>
              </XPath>
            </MsDeploySkipRules>
            <MsDeploySkipRules Include="SkipDeleteAppData">
              <SkipAction>Delete</SkipAction>
              <ObjectName>dirPath</ObjectName>
              <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
              <XPath>
              </XPath>
            </MsDeploySkipRules>
          </ItemGroup>
      </Target>
      
    2. Package, do not deploy the project. This will create a zip file and .cmd file in the target directory (defined by “Location where package will be created” on the Package/Publish Web Tab). By default, this is obj\Debug\Package (or obj\Release\Package)
    3. Deploy the site using the the resulting command file

    In my testing, you must package and run the command file. The project file tweaks will tell msbuild to put the necessary -skip rule into the command file. However, using the “publish” feature straight from VS 2010 doesn’t seem to run the command file (see the warning on this walkthrough)…it calls msdeploy directly and doesn’t seem to honor the project file skip rules. I believe this is the difference between VS using msbuild -T:Package and msbuild -T:MsDeployPublish to build the project, but I have not tested this.

    Finally, the command file isn’t quite correct, at least in VS 2010 SP1. There’s a great description of what goes wrong in this SO answer, but basically, VS (or maybe the /t:Package target is a better culprit) sets up the command file to publish to the machine without specifying a site. To fix that, you’ll need to somehow get “?site=sitename” (probably this is ?site=Default+Web+Site, for a full URL of https://machine:8172/MsDeploy.axd?site=Default+Web+Site) onto the end of the computerName argument.

    The problem I had was that the command file (batch file) has a hard time with using site= anything on the command line since it mis-parses the command line argument (even if escaped). I don’t see a way around this problem other than modifying the cmd file directly, but for testing I copied the msdeploy.exe output I saw from my failed test run and modified that to call msdeploy.exe directly without the script.

    Now that it’s working, my intention is to work this into my CI build processes. What I’ll be doing for the final solution is:

    1. Change my build script to use /T:Package (right now it’s /T:MsDeploy)
    2. Have a scripted search/replace routine alter the generated cmd deployment script
    3. Run the altered deployment script

    This really should be easier.

    Update

    Here’s the scripted search/replace routine I’ve come up with in PowerShell:

    (Get-Content "project.deploy.cmd") 
      -replace('^set _ArgComputerName=$'
               ,"set  ArgComputerName=https://server:8172/MsDeploy.axd?Site=Default+Web+Site") 
      | Out-File -Encoding ascii deploy.cmd
    

    Once that is run, deploy.cmd can be called (without the /M option) and it will work as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following setup. I have a web application and in the .css
I have the following setup: Intranet Application --> Call WCF Web Api --> Calls
In my ASP.NET MVC application, I have the following setup: <runtime> <assemblyBinding xmlns=urn:schemas-microsoft-com:asm.v1> <probing
Hi I have a setup project in my application.Setup includes 5 files (a.txt,b.doc etc.)
ISS and ASP.NET. In my setup I have a web application that must be
Setup : I have a Struts web application where I use displaytag elements to
So my setup for my web application is that I have a general header
I have a .NET 3.5 Setup Package Project which installs my application successfully. The
I have a simple console application where I have the following setup: public interface
I have a simple application with the following code: FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.