Web Deployment Tool (MS Deploy)
Avoid deleting App_Data folder when publishing?
Last post Mar 04, 2013 11:04 PM by leodegan
Sep 19, 2012 06:23 PM|LINK
I am using Visual Studio 2012 and WebDeploy 3.0 to deploy my MVC 4 web app to my Windows Server 2008 R2. I have set the option to "Remove additional files at destination", but want to keep the App_Data folder and all its content intact, since this is where
the database and all other user content is stored. At the same time, I want the application files to be "cleaned up" when I make changes to the application, so the option to "Remove additional files at destination" should apply to everything except the App_Data
How do I achieve this?
Thanks in advance!
visual studio 2012
Remove additional files at destination
Sep 21, 2012 03:15 AM|LINK
You can deploy manually from command prompt. Then invoke a skip rule:
Make MSDeploy (Visual Studio) not delete App_Data folder but delete everything else
Sep 22, 2012 10:48 AM|LINK
Thanks for your answer!
Is it possible to achieve this without having to publish from the command prompt? I would much rather like to use the UI in visual studio, since it is much faster to use (in my opinion).
I have achieved making custom folders at the deployment destination by creating a file [projectname].wpp.targets in the project folder and specifying some XML, but the XML-property used to skip certain rules does not seem to work.
Thanks in advance!
Sep 23, 2012 08:14 AM|LINK
Technically you should just be able to define a <SkipApp_DataFolder>true</SkipApp_DataFolder> property in your wpp.targets, but I've seen instances where it doesn't work.
If you run into that problem, try adding the following to your wpp.targets (it's just the WPP equivalent to the MSDeploy skip directive)
Sep 30, 2012 03:09 PM|LINK
Thanks for the answers! Sorry for the late response... had to prepare for a master thesis defence.
I have seen the proposition of using the projectname.wpp.targets file on a lot of other forums, but I couldn't get it to work properly. Instead I decided to create a custom command prompt script that does what I want.
The script uses a set of credentials stored in the Windows Credential Manager (since I do not want the plain text credentials to show in the .bat file!!). I also use the publish file (that is, the .pubxml file) I was using before, so that I can easily control
the additional publish settings directly from Visual Studio.
This way I get all the very nice database migration features when using code first and at the same time I am ble clear up the whole deployment directory except for the content of the "App_Data"-folder.
If others are interested, the script is shown beneath. The last part just deletes the package files after publishing (it is ugly, I know, but it works). This script can be run from the package manager console, so that all work can be done inside VS2012:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe" "%rootLocalFolder%\%appname%\%appname%.sln" /v:q /t:build /p:Configuration=%buildtype%;DeployOnBuild=true;DeployTarget=Package;PublishProfile=%publishProfileName%
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.zip' -dest:auto,computerName="https://%serveraddress%:8172/MSDeploy.axd",getCredentials="%deployCredentials%",authtype="basic",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile="%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.SetParameters.xml" -setParam:name='IIS Web Application Name',value='%sitename%' -AllowUntrusted -skip:Directory='\\App_Data'
I don't know it this is the best way (probably not), but it works quite nicely and gives a lot of customizability in the deployment script. If you have any comments, don't hesitate to answer.
Mar 04, 2013 11:04 PM|LINK
I also have been using Visual Studio 2012/Web Deploy 3.0 and had spent a couple hours trying to get the ProjectName.wpp.targets file to work from everything I found posted, and what finally worked for me was the following:
The secret seemed to deal with the AbsolutePath entry. Most posts I found used some type of regular expression, none of which worked. What worked for me was just "App_Data" there.