MSBuild transform not evaluating wildcards

天大地大妈咪最大 提交于 2019-12-10 10:53:34

问题


I am having some trouble with a MSBuild file that I am trying to compile some custom libraries.

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

When I run this through MSBuild, all of the compiles work, but the copy files does not. MSBuild complains with the following errors:

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.

I am unable to figure out why the transform in the "LibsToCopy" ItemGroup isn't expanding the filename wildcards.

I have also attempted to use xcopy, but it doesn't like the wildcards either.

Thanks! Dave


回答1:


I had a similar problem. Try this, just before the <Copy> task

<CreateItem Include="@(LibsToBuild->'%(FullPath)\%(Version)\%(Bin)')">
  <Output TaskParameter="Include" ItemName="LibsToCopy" />
</CreateItem>

Unfortunately the documentation says CreateItem task is deprecated, so I don't know how to solve tis problem in the future.



来源:https://stackoverflow.com/questions/3396716/msbuild-transform-not-evaluating-wildcards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!