开发者

MSBuild, CreateItem to ItemGroup to binplace a target to multiple folders

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 wh开发者_StackOverflow中文版at 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>


<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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜