Using the dirPath Provider Using WebDeploy

I have a wcf application hosted in iis that I am trying to package using webdeploy. Everything works fine with visual studio tools, but I also need to create a log folder and set permissions for it. To do this, I created the ProjectName.wpp.target file in my web project. The file is as follows:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="CreateLogsDirectory" AfterTargets="AddIisSettingAndFileContentsToSourceManifest"> <!-- This must be declared inside of a target because the property $(_MSDeployDirPath_FullPath) will not be defined at that time. --> <ItemGroup> <MsDeploySourceManifest Include="dirPath"> <Path>$(_MSDeployDirPath_FullPath)\logs</Path> <enableRule>DoNotDeleteRule</enableRule> </MsDeploySourceManifest> </ItemGroup> </Target> <Target Name="DeclareCustomParameters" AfterTargets="AddIisAndContentDeclareParametersItems"> <!-- This must be declared inside of a target because the property $(_EscapeRegEx_MSDeployDirPath) will not be defined at that time. --> <ItemGroup> <MsDeployDeclareParameters Include="LogsDirectoryPath"> <Kind>ProviderPath</Kind> <Scope>dirPath</Scope> <Match>^$(_EscapeRegEx_MSDeployDirPath)\\logs$</Match> <Value>$(_DestinationContentPath)/log</Value> <ExcludeFromSetParameter>True</ExcludeFromSetParameter> </MsDeployDeclareParameters> </ItemGroup> </Target> </Project> 

I see that the dirPath provider is being added to the source file, but when I deploy the package, it tries to create the path to the source file. In essence, the LogsDirectoryPAth element does not replace the path. can someone point out what i need to do? thanks!

+1
source share
1 answer

Given that your secondary directory is inside your web application, it is not necessary to include another dirPath provider, and this will only lead to more headaches (additional parameter declarations, etc.).

Here are some helpers I use to help with this. Your specific application values ​​can be declared in your wpp.targets file:

 <!-- Items specific to your application (these should be in your wpp.targets) --> <ItemGroup> <SkipDeleteFiles Include="logs" /> <EmptyDirectoriesToDeploy Include="logs" /> <AdditionalAcls Include="logs"> <AclAccess>Write</AclAccess> </AdditionalAcls> </ItemGroup> 

And the following conventions-based definitions can either be placed in you wpp.targets , or in a general goals file that you can import into your wpp.targets :

 <!-- Empty directories --> <PropertyGroup> <BeforeAddContentPathToSourceManifest> $(BeforeAddContentPathToSourceManifest); CreateEmptyDirectories; </BeforeAddContentPathToSourceManifest> </PropertyGroup> <Target Name="CreateEmptyDirectories"> <MakeDir Directories="$(_MSDeployDirPath_FullPath)\%(EmptyDirectoriesToDeploy.Identity)" Condition="'@(EmptyDirectoriesToDeploy)' != ''" /> </Target> <!-- Additional ACLs --> <ItemDefinitionGroup> <AdditionalAcls> <AclAccess>Write</AclAccess> <ResourceType>Directory</ResourceType> </AdditionalAcls> </ItemDefinitionGroup> <PropertyGroup> <AfterAddIisSettingAndFileContentsToSourceManifest> $(AfterAddIisSettingAndFileContentsToSourceManifest); AddAdditionalAclsToSourceManifest; </AfterAddIisSettingAndFileContentsToSourceManifest> <AfterAddIisAndContentDeclareParametersItems> $(AfterAddIisAndContentDeclareParametersItems); AddAdditionalAclsDeclareParameterItems </AfterAddIisAndContentDeclareParametersItems> </PropertyGroup> <Target Name="AddAdditionalAclsToSourceManifest"> <ItemGroup Condition="'@(AdditionalAcls)' != ''"> <MsDeploySourceManifest Include="setAcl"> <Path>$(_MSDeployDirPath_FullPath)\%(AdditionalAcls.Identity)</Path> <setAclResourceType Condition="'%(AdditionalAcls.ResourceType)' != ''">%(AdditionalAcls.ResourceType)</setAclResourceType> <setAclAccess>%(AdditionalAcls.AclAccess)</setAclAccess> <AdditionalProviderSettings>setAclResourceType;setAclAccess</AdditionalProviderSettings> </MsDeploySourceManifest> </ItemGroup> </Target> <Target Name="AddAdditionalAclsDeclareParameterItems"> <ItemGroup Condition="'@(AdditionalAcls)' != ''"> <MsDeployDeclareParameters Include="Add %(AdditionalAcls.AclAccess) permission to %(AdditionalAcls.Identity) Folder"> <Kind>ProviderPath</Kind> <Scope>setAcl</Scope> <Match>^$(_EscapeRegEx_MSDeployDirPath)\\@(AdditionalAcls)$</Match> <Description>Add %(AdditionalAcls.AclAccess) permission to %(AdditionalAcls.Identity) Folder</Description> <DefaultValue>{$(_MsDeployParameterNameForContentPath)}/@(AdditionalAcls)</DefaultValue> <DestinationContentPath>$(_DestinationContentPath)/@(AdditionalAcls)</DestinationContentPath> <Tags>Hidden</Tags> <ExcludeFromSetParameter>True</ExcludeFromSetParameter> <Priority>$(VsSetAclPriority)</Priority> </MsDeployDeclareParameters> </ItemGroup> </Target> <!-- Skip delete files and directories --> <PropertyGroup> <ImportPublishingParameterValuesDependsOn> $(ImportPublishingParameterValuesDependsOn); AddSkipDirectives; </ImportPublishingParameterValuesDependsOn> </PropertyGroup> <ItemGroup> <SkipDeleteItems Include="@(SkipDeleteFiles)" Condition="'@(SkipDeleteFiles)' != ''"> <Provider>filePath</Provider> </SkipDeleteItems> <SkipDeleteItems Include="@(SkipDeleteDirectories)" Condition="'@(SkipDeleteDirectories)' != ''"> <Provider>dirPath</Provider> </SkipDeleteItems> </ItemGroup> <!-- Uses MSBuild trickery to add an escaped version of the skip path to as "EscapedPath" metadata --> <Target Name="AddRegexEscapedPathMetadata" Outputs="%(SkipDeleteItems.EscapedPath)"> <EscapeTextForRegularExpressions Text="%(SkipDeleteItems.Identity)"> <Output TaskParameter="Result" PropertyName="_Temp_EscapeRegEx_SkipDeleteItemPath" /> </EscapeTextForRegularExpressions> <ItemGroup> <SkipDeleteItems Condition="'%(SkipDeleteItems.Identity)' == '%(Identity)'" > <EscapedPath>$(_Temp_EscapeRegEx_SkipDeleteItemPath)</EscapedPath> </SkipDeleteItems> </ItemGroup> <PropertyGroup> <!-- Clear value --> <_Temp_EscapeRegEx_SkipDeleteItemPath></_Temp_EscapeRegEx_SkipDeleteItemPath> </PropertyGroup> </Target> <Target Name="AddSkipDirectives" DependsOnTargets="AddRegexEscapedPathMetadata"> <ItemGroup> <MsDeploySkipRules Include="%(SkipDeleteItems.Identity)"> <SkipAction>Delete</SkipAction> <ObjectName>%(SkipDeleteItems.Provider)</ObjectName> <AbsolutePath>%(SkipDeleteItems.EscapedPath)</AbsolutePath> </MsDeploySkipRules> </ItemGroup> </Target> 

NB If you make an extra effort to separate the packaging process from the deployment process, then technically your SkipDeleteFiles should be in your pubxml and not in your wpp.targets .

+5
source

Source: https://habr.com/ru/post/1439968/


All Articles