MSBuild转换不评估通配符

时间:2010-08-03 13:06:29

标签: msbuild transform

我正在尝试编译一些自定义库的MSBuild文件时出现问题。

    

<PropertyGroup>
    <FullVersion>10.8.0.0</FullVersion>
</PropertyGroup>

<ItemGroup>
    <LibsToBuild Include=".\Lib1">
        <Bin>bin\*.*</Bin>
        <Project>Library 1</Project>
        <Build>ReleaseNoProtect</Build>
        <Version>CurrentVersion</Version>
    </LibsToBuild>

    <LibsToBuild Include=".\Lib2">
        <Bin>bin\*.*</Bin>
        <Project>Library 2</Project>
        <Build>ReleaseLibrary</Build>
        <Version>CurrentVersion</Version>
    </LibsToBuild>      
</ItemGroup>

<ItemGroup>    
    <LibsToCopy Include="@(LibsToBuild->'%(FullPath)\%(Version)\%(Bin)')" />
</ItemGroup>

<Target Name="BuildLibs">
    <MSBuild
        Projects="@(LibsToBuild->'%(FullPath)\%(Version)\Build\Build.proj')"
        Targets="%(LibsToBuild.Build)"
        Properties="Configuration=Release;APP_VERSION=$(FullVersion);PROJECT_NAME=%(LibsToBuild.Project)"
    />

    <Copy
        SourceFiles="@(LibsToCopy)"
        DestinationFiles="@(LibsToCopy->'.\Libraries\CurrentVersion\%(RecursiveDir)%(Filename)%(Extension)')"
    />

    <!--
    <Exec Command='xcopy /y @(LibsToCopy) .\Libraries\CurrentVersion' />
    -->
</Target>

当我通过MSBuild运行时,所有编译都有效,但复制文件没有。 MSBuild抱怨以下错误:

Copying file from "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*".
X:\Projects\Test Release.build(35,3): error MSB3021: Unable to copy file "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*". Illegal characters in path.
Copying file from "X:\Projects\Lib2\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*".
X:\Projects\Test Release.build(35,3): error MSB3021: Unable to copy file "X:\Projects\Lib1\Master\bin\*.*" to ".\Libraries\CurrentVersion\*.*". Illegal characters in path.

我无法弄清楚为什么“LibsToCopy”ItemGroup中的转换没有扩展文件名通配符。

我也试图使用xcopy,但它也不喜欢通配符。

谢谢! 戴夫

1 个答案:

答案 0 :(得分:1)

我有类似的问题。在<Copy>任务

之前尝试此操作
<CreateItem Include="@(LibsToBuild->'%(FullPath)\%(Version)\%(Bin)')">
  <Output TaskParameter="Include" ItemName="LibsToCopy" />
</CreateItem>

不幸的是文档说CreateItem任务已被弃用,所以我不知道将来如何解决这个问题。