短篇小说:我有一个名为true的属性列表。我想将所有这些文件复制到文件夹列表中,例如由...定义
someFolder
为此,这就是我今天要做的事情:
<CreateItem Include="%(Reference.HintPath)"
Condition="'%(Reference.Binplace)' == 'true'"
AdditionalMetadata="DestinationFolder=$(DestinationForReferences)\%(Reference.BinplaceFolder)">
<Output ItemName="Binplace" TaskParameter="Include" />
</CreateItem>
我已经有一个名为Binplace的目标,它在内部调用Copy。问题是这是一个单独的元素,我不知道如何在多个这些项目上调用复制
在我的CSPROJ文件中,我这样做:
<Reference Include="MyCompany.Something.Something">
<HintPath>$(LocalLibraryFolder)\MyCompany.Something.Something.dll</HintPath>
<Binplace>true</Binplace>
</Reference>
答案 0 :(得分: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>