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-only attribute from the myFile.ext file in the solution folder.
Advertisements

4 Responses to Changing a file’s attribute from a MSBuild script

  1. Jeroen Van Malderen says:

    This snippet could result in following error during build: “parameter format not correct -”
    You can prevent it changing it to:

  2. Jeroen Van Malderen says:

    Apparently it didn’t copied over the xml I added. So the solution is to add " before and after $(SolutionRoot)\myFile.ext

  3. Jeroen Van Malderen says:

    Of course I meant the html encoded quotation for quote otherwise your xml tag won’t be valid.

    Sorry for filling up your comments, if possible remove all comments and add an aggregated comment to or edit of your post

  4. Asit Jena says:

    Good. able to remove readonly from file. but how could do it for ” From a Folder” not for individual files.?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: