1

Short-story: I have a list of with an attribute called true. I want to copy all of these files, to a list of folders, say defined by ...

someFolder

To that end, here's what I'm doing today:

    <CreateItem Include="%(Reference.HintPath)"
                Condition="'%(Reference.Binplace)' == 'true'"
                AdditionalMetadata="DestinationFolder=$(DestinationForReferences)\%(Reference.BinplaceFolder)">
        <Output ItemName="Binplace" TaskParameter="Include" />
    </CreateItem>

I already have a target called Binplace which internally calls Copy. The problem is that is a single element, and I don't know how I can call Copy on multiple of these items

And in my CSPROJ file, I do this:

    <Reference Include="MyCompany.Something.Something">
        <HintPath>$(LocalLibraryFolder)\MyCompany.Something.Something.dll</HintPath>
        <Binplace>true</Binplace>
    </Reference>
gaganuprasad
  • 31
  • 1
  • 4
  • Sorry, read this three times and I have no idea what you are trying to accomplish, or what the problem is, could you add a bunch of additional detail to your question? – Brian Kretzler Apr 20 '11 at 04:25
  • Added more info, does this help? – gaganuprasad Apr 20 '11 at 05:03
  • Your text mentions a folder named "someFolder" but I don't see it referenced in the msbuild. You need to show your "Binplace" target. How does the "Binplace" target relate to the .csproj, is it in an imported targets file or a separate MSBuild project? – Brian Kretzler Apr 20 '11 at 14:43

1 Answers1

1
<ItemGroup>
    <Reference Include="1">
        <HintPath>$(LocalLibraryFolder)\1.dll</HintPath>
        <Binplace>true</Binplace>
        <BinplaceFolder>SubFolder1\SubFolder12</BinplaceFolder>
    </Reference>
    <Reference Include="2">
        <HintPath>$(LocalLibraryFolder)\2.dll</HintPath>
        <Binplace>true</Binplace>
        <BinplaceFolder>SubFolder2\SubFolder22</BinplaceFolder>
    </Reference>
</ItemGroup>
<PropertyGroup>
     <LocalLibraryFolder>.</LocalLibraryFolder>
     <DestinationForReferences>.</DestinationForReferences>
</PropertyGroup>

<Target Name="CopyReferencedBinaries"
        Outputs="%(Reference.Identity)">    
     <ItemGroup>
          <SourceBinaryFullPath Include="%(Reference.HintPath)" />              
     </ItemGroup>
     <PropertyGroup>
          <SourceBinaryDir>$(DestinationForReferences)\%(Reference.BinplaceFolder)</SourceBinaryDir>
     </PropertyGroup>
     <MakeDir Directories="$(SourceBinaryDir)"
              Condition="!Exists('$(SourceBinaryDir)')"/>
     <Copy SourceFiles="@(SourceBinaryFullPath)"
           DestinationFiles="@(SourceBinaryFullPath->'$(SourceBinaryDir)\%(Filename)%(Extension)')" />
</Target>
Sergio Rykov
  • 4,176
  • 25
  • 23
  • you might have got this the other way round. I need my propertygroup to have a list of locations to deploy to. so folder1folder2 – gaganuprasad Apr 20 '11 at 13:51
  • And Binplacefolder just means drop this specific one elsewhere, but if this field is not present, drop it in all the locations mentioned by the propertygroup – gaganuprasad Apr 20 '11 at 13:52
  • @gaganuprasad I think you're confused how the PropertyGroup construct works. It only allows you to create distinct variables, not collections. The PropertyGroup tag simply allows you to group these properties into the same location in the xml and does not make them related in any other way. – porusan Apr 20 '11 at 14:37