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
folder
How do I achieve this?
Thanks in advance!
App_Datavisual studio 2012MVC 4WebDeploy 3.0Remove additional files at destination
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.
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)
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:
set appname=APPLICATION_NAME
set publishProfileName=NAME_OF_PUBLISH_PROFILE
set buildtype=Debug
set sitename=IIS_SITE_NAME
set serveraddress=IP_OF_TARGET_SERVER
set rootLocalFolder=c:\FOLDER_PATH
set deployCredentials=USER_STORED_USING_WINDOWS_CREDENTIAL_MANAGER
"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'
del "%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.deploy.cmd"
del "%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.deploy-readme.txt"
del "%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.SetParameters.xml"
del "%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.SourceManifest.xml"
del "%rootLocalFolder%\%appname%\%appname%\obj\%buildtype%\Package\%appname%.zip"
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.
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.
Jesperk
5 Posts
Avoid deleting App_Data folder when publishing?
Sep 19, 2012 06:23 PM|LINK
Hi
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 folder
How do I achieve this?
Thanks in advance!
App_Data visual studio 2012 MVC 4 WebDeploy 3.0 Remove additional files at destination
Dalong Zhang...
647 Posts
Microsoft
Re: Avoid deleting App_Data folder when publishing?
Sep 21, 2012 03:15 AM|LINK
Hi,
You can deploy manually from command prompt. Then invoke a skip rule:
-skip:Directory=\\App_Data
Make MSDeploy (Visual Studio) not delete App_Data folder but delete everything else
http://stackoverflow.com/questions/4289440/make-msdeploy-visual-studio-not-delete-app-data-folder-but-delete-everything-e
Feedback to us
Develop and promote your apps in Windows Store
Jesperk
5 Posts
Re: Avoid deleting App_Data folder when publishing?
Sep 22, 2012 10:48 AM|LINK
Hi Dalong
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!
richard.szal...
83 Posts
Re: Avoid deleting App_Data folder when publishing?
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)
<ItemGroup>
<MsDeploySkipRules Include="SkipAppDataOnDeploy">
<SkipAction>Delete</SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>App_Data$</AbsolutePath>
<XPath></XPath>
</MsDeploySkipRules>
</ItemGroup>
Jesperk
5 Posts
Re: Avoid deleting App_Data folder when publishing?
Sep 30, 2012 03:09 PM|LINK
Hi
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:
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.
leodegan
1 Post
Re: Avoid deleting App_Data folder when publishing?
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:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <OnBeforePackageUsingManifest>AddCustomSkipRules</OnBeforePackageUsingManifest> </PropertyGroup> <Target Name="AddCustomSkipRules"> <ItemGroup> <MsDeploySkipRules Include="SkipAppData"> <SkipAction>Delete</SkipAction> <ObjectName>dirPath</ObjectName> <AbsolutePath>App_Data</AbsolutePath> <XPath></XPath> </MsDeploySkipRules> </ItemGroup> </Target> </Project>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.