Reputation: 1863
I've edited my csproj file according to this post, but the extra files in App_data will be deleted anyway. On the other hand, when I modify the msdeploy command as shown in the post, the skip is applied.
I'm using web deploy v3. And the command is
msdeploy.exe" -verb:sync -source:package=c:\builds\app.zip -dest:auto -setParam:"IIS Web Application Name"="Default Web Site/app"
Is there anyway to debug what can be causing this behavior ?
<PropertyGroup> <OnBeforePackageUsingManifest>AddCustomSkipRules</OnBeforePackageUsingManifest>
</PropertyGroup>
<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>
Upvotes: 2
Views: 444
Reputation: 3423
I've been reviewing the Microsoft.Web.Publishing.targets and it looks like this is already implemented, all you need to do is add this property to your MsBuild script:
<PropertyGroup>
<SkipApp_DataFolder>True</SkipApp_DataFolder>
</PropertyGroup>
If you are running from msbuild command line you can use:
msbuild MyProject.csproj /p:SkipApp_DataFolder=True ...
UPDATE:
You may want to try this, put this code at the bottom of your MsBuild file, after any "Import" tags:
<Target Name="GenerateSkipRuleForAppData">
<EscapeTextForRegularExpressions Text="$(_PackageTempDir)">
<Output TaskParameter="Result" PropertyName="_Escaped_PackageTempDir" />
</EscapeTextForRegularExpressions>
<ItemGroup>
<MsDeploySkipRules Include="SkipAddDataOnDeploy">
<SkipAction></SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data$</AbsolutePath>
<XPath></XPath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
This is an exact copy of the "GenerateSkipRuleForAppData" target from Microsoft.Web.Publishing.targets without a condition (seems like the condition is not working properly), this will overwrite the original target and should force it to be executed without break the logic of the targets.
Upvotes: 2