Skip to content

Add "Remove ReadOnly-Attribute" method #6

@robertmuehsig

Description

@robertmuehsig

I raise this issue as a result of a gitter discussion.

My scenario: I have a couple of .config files checked in the source control (TFS VC), which needs to be replaced (or re-generated) before I invoke MSBuild.
I use "DeleteFiles" and/or "CleanDirectories" for this kind of stuff from Cake, but both will fail because they refuse to delete "read-only" protected files.

Gary told me that this behavior is by design and is in most cases the logical choice. He pointed me to the FileHelper addin - maybe this would be a good place for this kind of functionality.

My current workaround is trivial:

public void EnsureFileIsWritable(string filePath)
{
    System.IO.File.SetAttributes(filePath, FileAttributes.Normal);
}

If you are interested in a PR just let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions