Search code examples
visual-studiomsbuildmsbuild-taskmsbuild-4.0

MsBuild: Add text or custom information to the files


The below code works fine to copy the files from Source to the Destination folder. I want to make the copied files in order for example 1.zip.exe 2.NetFx.exe etc... or I.zip.exe II.NetFx.exeetc....

Basically I want to tell the user to install the tools in order. How can I do this??? Please give me some idea...!

 <PropertyGroup Condition="'$(OutDir)'==''">
          <OutDir>..\..\..\OutputSetup\</OutDir>
    </PropertyGroup>

    <ItemGroup>
        <SourceFiles Include="..\tools\zip\**\*.*"/>
        <SourceFiles Include="..\tools\NetFx\**\*.*"/>
    </ItemGroup>


    <Target Name="CopyTools">

            <Copy SourceFiles="@(SourceFiles)" DestinationFiles="@($(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
    </Target>

Solution

  • I hope you can solve this issue as following a code like below:

    <PropertyGroup Condition="'$(OutDir)'==''">
      <OutDir>..\..\..\OutputSetup\</OutDir>
    </PropertyGroup>
    
    <ItemGroup>
        <SourceFiles Include="..\tools\zip\**\*.*">
           <Number>1</Number>
        </SourceFiles>
        <SourceFiles Include="..\tools\NetFx\**\*.*">
           <Number>2</Number>
        </SourceFiles>
    </ItemGroup>
    
    
    <Target Name="CopyTools">
    
        <Copy SourceFiles="@(SourceFiles)" DestinationFiles="@($(OutDir)\%(SourceFiles.Number)%(RecursiveDir)%(Filename)%(Extension)" />
    </Target>