MSBuild、CreateItem 到 ItemGroup 将目标 binplace 到多个文件夹

发布于 2024-11-02 03:41:21 字数 811 浏览 1 评论 0原文

简短的故事:我有一个名为 true 的属性的列表。我想将所有这些文件复制到文件夹列表中,例如由...

someFolder

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

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无风消散 2024-11-09 03:41:21
<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>
<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文