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

发布于 2025-01-02 05:01:28 字数 3553 浏览 0 评论 0原文

我需要确保某些上传目录始终具有网络服务的写入权限。我创建了一个 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 有关。

如何让网络服务写入这些目录?我需要在项目属性中显式添加一些内容吗?

理查德

I need to ensure some upload directories always have write access for Network Service. I created a ProjectName.wpp.targets XML file containing configuration to add this in during the publishing process in Visual Studio 2010 but it doesn't seem to work. There are no errors but write access is not applied. I restart VS after any change, so it's not caching a previous version. Here's my 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
lt;/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
lt;/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>

I am publishing to a network file share, so perhaps that is something as all the examples I can find (not many) are concerned with IIS.

How to get Network Service writing to those directories? Do I need to explicitly add something in the project properties?

Richard

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文