Nant:更改文件权限
我有一个 ASP.NET 应用程序。 基本上,交付过程是这样的:
- Nant 构建应用程序,并在开发人员的计算机上创建一个 zip 文件,其中包含应用程序文件,不含 SVN 文件夹和无用文件。 该文件与 Nant 脚本一起提供。
- zip 和 nant 文件被复制到客户端计算机,
- Nant 脚本将当前网站文件替换为 zip 文件中包含的文件。
我的问题是,通过此过程,当我尝试打开该网站时出现未经授权的访问错误。 这些文件似乎需要为用户“IIS_WPG”设置权限。
我无权更改 IIS 配置,因此我必须手动更改每个文件的权限。 每次替换文件时,权限都会被删除,我需要再次设置它们。
所以我有两个问题:
- 我可以使用 Nant 更改文件权限吗? 怎么做 ?
- 有可能避免这个问题吗? (开发者的计算机上没有该用户)
I have an ASP.NET application.
Basically the delivery process is this one :
- Nant builds the application and creates a zip file on the developer's computer with the application files without SVN folders and useless files. This file is delivered with a Nant script.
- The zip and nant files are copied to the client's computer
- the Nant script replaces the current website files with the file contained in the zip file.
My problem is that with this process I have an Unauthorized access error when I try to open the website.
It seems that the files need to have a permission set for the user "IIS_WPG".
I don't have the power to change IIS configuration so I have to manually change the permissions of each file. And each time I replace the files the permissions are removed and I need to set them again.
So I have two questions :
- Can I change files permissions with Nant ? How to do it ?
- Is it possible to avoid this problem ? (developers don't have this user on their computers)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
@杰夫·弗里茨
哎哟...
您的建议是正确的解决方案,但参数很......危险:)。
在开发计算机上,我以管理员身份登录,并使用 cmd 尝试了您的建议。
因此,经过一些测试,正确的命令是:
@Jeff Fritz
Ouch...
Your suggestion is the right solution but the parameters are... dangerous :).
On dev computers I'm logged as administrator and I tried your suggestion with cmd.
So, after some tests, the right command is :
您需要在Windows中运行CACLS程序来授予文件和文件夹权限。 在 Nant 中,您可以使用 EXEC 任务来完成此操作。
尝试使用如下标签块:
You need to run the CACLS program in windows to grant permissions to files and folders. From Nant, you can do this with the EXEC task.
Try a tag block like:
我们最终用一些相当简单的代码为此编写了自己的任务:
然后您可以编写一个加载自定义任务并执行的 nant 脚本:
显然,这可以根据您的某些规则进行修改,或者您甚至可以在任务中对其进行参数化如果你愿意的话。 我们更喜欢这个而不是使用 exec 任务,因为它让我们对正在应用的权限有更多的控制。
We ended up writing our own task for this with some fairly straight forward code:
Then you can write a nant script that loads the custom task and executes:
Obviously, this could be modified for your certain rules or you could even parameterize this in the task if you so wish. We preferred this over the using the exec task as it have us a bit more control over permissions that were being applied.
CACLS 现已弃用。 这是使用 ICACLS 的替代版本。
假设我们有以下内容:
${paths.myprogram.inetpub}
中${upload.foldername}
${iis.upload.user}
${iis.user.permissionlevel}
有了这些假设,我们的任务是这样的:
希望这样有帮助!
CACLS is now deprecated. Here's a version that uses ICACLS, the replacement.
Let's say we have the following:
${paths.myprogram.inetpub}
${upload.foldername}
${iis.upload.user}
${iis.user.permissionlevel}
With these assumptions, our task is this:
Hope this helps!