如何使用VS2010发布为网络服务添加文件夹写入权限?

时间:2012-02-03 02:45:00

标签: visual-studio-2010 msbuild

我需要确保一些上传目录始终具有网络服务的写访问权限。我创建了一个ProjectName.wpp.targets XML文件,其中包含在Visual Studio 2010中的发布过程中添加它的配置,但它似乎不起作用。没有错误,但未应用写访问权限。我在任何更改后重新启动VS,因此它不会缓存以前的版本。这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="SetupCustomAcls" AfterTargets="AddIisSettingAndFileContentsToSourceManifest">
        <ItemGroup>
            <MsDeploySourceManifest Include="setAcl">
                <Path>$(_MSDeployDirPath_FullPath)\Assets\Uploads\FirstFolder</Path>
                <setAclAccess>Read,Write</setAclAccess>
                <setAclResourceType>Directory</setAclResourceType>
                <AdditionalProviderSettings>setAclResourceType;setAclAccess</AdditionalProviderSettings>
            </MsDeploySourceManifest>
            <MsDeploySourceManifest Include="setAcl">
                <Path>$(_MSDeployDirPath_FullPath)\Assets\Uploads\SecondFolder</Path>
                <setAclUser>NETWORK SERVICE</setAclUser>
                <setAclAccess>Read,Write</setAclAccess>
                <setAclResourceType>Directory</setAclResourceType>
                <AdditionalProviderSettings>setAclUser;setAclResourceType;setAclAccess</AdditionalProviderSettings>
            </MsDeploySourceManifest>
        </ItemGroup>
    </Target>
    <Target Name="DeclareCustomParameters" AfterTargets="AddIisAndContentDeclareParametersItems">
        <ItemGroup>
            <MsDeployDeclareParameters Include="FirstFolderSetAclParam">
                <Kind>ProviderPath</Kind>
                <Scope>setAcl</Scope>
                <Match>^$(_EscapeRegEx_MSDeployDirPath)\\Assets\\Uploads\\FirstFolder$</Match>
                <Description>Add write permission to the FirstFolder.</Description>
                <DefaultValue>{$(_MsDeployParameterNameForContentPath)}/Assets/Uploads/FirstFolder</DefaultValue>
                <Value>$(_DestinationContentPath)/Assets/Uploads/FirstFolder</Value>
                <Tags>Hidden</Tags>
                <Priority>$(VsSetAclPriority)</Priority>
                <ExcludeFromSetParameter>True</ExcludeFromSetParameter>
            </MsDeployDeclareParameters>
            <MsDeployDeclareParameters Include="SecondFolderSetAclParam">
                <Kind>ProviderPath</Kind>
                <Scope>setAcl</Scope>
                <Match>^$(_EscapeRegEx_MSDeployDirPath)\\Assets\\Uploads\\SecondFolderFuelBills$</Match>
                <Description>Add write permission to the SecondFolder.</Description>
                <DefaultValue>{$(_MsDeployParameterNameForContentPath)}/Assets/Uploads/SecondFolder</DefaultValue>
                <Value>$(_DestinationContentPath)/Assets/Uploads/SecondFolder</Value>
                <Tags>Hidden</Tags>
                <Priority>$(VsSetAclPriority)</Priority>
                <ExcludeFromSetParameter>True</ExcludeFromSetParameter>
            </MsDeployDeclareParameters>
        </ItemGroup>
    </Target>
</Project>

我正在发布到网络文件共享,所以也许这就是我能找到的所有示例(不是很多)都与IIS有关。

如何让网络服务写入这些目录?我是否需要在项目属性中明确添加内容?

理查德

0 个答案:

没有答案