Tuesday, October 30, 2007

Changing a file's attribute from a MSBuild script

This is a pretty simple one but it took me a little time figuring it out as I don't have prior MSBuild experience. Basically, you just need to use the Exec with the command attribute

<Exec Command="attrib -R $(SolutionRoot)\myFile.ext" />

This will remove the read-ony attribute from the myFile.ext file in the solution folder.

3 comments:

Elan Hasson said...
This comment has been removed by the author.
Elan Hasson said...
This comment has been removed by the author.
Elan Hasson said...

To support paths with spaces in the name, use &quot; to quote it:

<Exec Command="attrib -R &quot;$(SolutionRoot)\myFile.ext&quot;" />