views:

329

answers:

2

Is there a way to get the CopyTask to copy the same file to multiple locations?

eg. I've generated an AssemblyInfo.cs file and want to copy it across to all my projects before building.

+2  A: 

Check out the RoboCopy build task which is part of the Community Build Tasks library which you can find here. RoboCopy can copy one source file to multiple destinations.

On a side note: why don't you use one AssemblyInfo file on solution level and link to that in your projects if you need the same information in every project? Check out my accepted answer on this question: http://stackoverflow.com/questions/610414/automatic-assembly-version-number-management-in-vs2008/610443#610443

Gerrie Schenck
Is the version packaged with the MSI on the community build tasks not the latest? Don't see the RoboCopy task after installing it... (It's not even in the documentation or sample project)
Veli
hmm strange, it's in the list on the website though
Gerrie Schenck
+1  A: 

Right, well maybe I should attempt to do the things I want to do before asking for help :)

    <ItemGroup>
        <AssemblyInfoSource 
            Include="AssemblyInfo.cs;AssemblyInfo.cs" />
        <AssemblyInfoDestination
            Include="$(Destination1)\AssemblyInfo.cs;$(Destination2)\AssemblyInfo.cs" />
    </ItemGroup>

    <Copy SourceFiles="@(AssemblyInfoSource)" DestinationFiles="@(AssemblyInfoDestination)" />
Veli
Thanks for sharing. Does the number of source and destination files have to be the same?
Gerrie Schenck
Yeah, the number of files needs to match. I'm presuming you _can_ rename the destination files if needed though. http://msdn.microsoft.com/en-us/library/3e54c37h.aspx(Though I definitely think the linked AssemblyInfo option is the best thing to do here, thanks for that :) this is just for completeness)
Veli