Remove attribute from file

Jan 23, 2009 at 2:40 PM
Edited Jan 23, 2009 at 2:41 PM
In the help there is an example how to set an attribute for a file: 

<ItemGroup>

 

 <

 

FilesToParse Include="c:\demo\file.txt"/>

 

 

 <

 

FilesToCount Include="C:\Demo\**\*.cs"/>

 

 

 <

 

AllFilesToCount Include="C:\Demo\**\*"/>

 

 

 <

 

AtFiles Include="c:\demo\file1.txt">

 

 

 <

 

Attributes>ReadOnly;Hidden</Attributes>

 

 

 </

 

AtFiles>

 

 

 <

 

AtFiles2 Include="c:\demo\file1.txt">

 

 

 <

 

Attributes>Normal</Attributes>

 

 

 </

 

AtFiles2>

 

 

 <

 

MyFiles Include="C:\demo\**\*.csproj"/>

 

 

 </

 

ItemGroup>

 

 

 

But how can I remove an attribute from a file? Thanks, in advance

Coordinator
Jan 23, 2009 at 4:33 PM
Hi

It's not currently possible. The logic taken is that the attributes passed would replace all existing attributes, that way the file is in a known state. If you have case where this really doesn't work for you, feel free to raise a work-item and describe your requirement.

Regards

Mike
Jan 24, 2009 at 5:39 PM

Hi Mike,

what I want to do is to set the AssemnlyInfoDescription. But I got an error message that the file is readonly.

Because of them I want to remove the the readonly flag from all the AssemblyInfo.cs files. Is there a solution to do this with the ExtensionPack?

Regards Roland

Coordinator
Jan 25, 2009 at 11:57 AM
not right now. I'll enhance the task. for now your easiest route is something like this:

        <ItemGroup>
            <WriteableFiles Include="$(SolutionRoot)\Development\**\AssemblyInfo.cs"/>
        </ItemGroup>

<Exec Condition="'%(WriteableFiles.Identity)'!=''" Command="attrib -r /S &quot;%(WriteableFiles.Identity)&quot;" />

<!-- DO YOUR STUFF HERE -->

<Exec Condition="'%(WriteableFiles.Identity)'!=''" Command="attrib +r /S &quot;%(WriteableFiles.Identity)&quot;" />
Coordinator
Jan 25, 2009 at 4:25 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.