1

短篇小说:我有一个列表,其中包含一个名为 true 的属性。我想将所有这些文件复制到文件夹列表中,例如由...定义

一些文件夹

为此,这就是我今天要做的事情:

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

我已经有一个名为 Binplace 的目标,它在内部调用 Copy。问题是这是一个单一的元素,我不知道如何在其中多个项目上调用 Copy

在我的 CSPROJ 文件中,我这样做:

    <Reference Include="MyCompany.Something.Something">
        <HintPath>$(LocalLibraryFolder)\MyCompany.Something.Something.dll</HintPath>
        <Binplace>true</Binplace>
    </Reference>
4

1 回答 1

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>
于 2011-04-20T10:58:38.807 回答