Search code examples
nantfile-permissions

Nant : change file permission


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)

Solution

  • 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:

    <exec program="cacls">
        <arg value="*" />
        <arg value="/G IIS_WPG:F" />
    </exec>