如何使用VS2010发布为网络服务的文件夹添加写权限?
我需要确保某些上传目录始终具有网络服务的写入权限。我创建了一个 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\\FirstFolderlt;/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\\SecondFolderFuelBillslt;/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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论