MSBuild 转换不评估通配符

发布于 2024-09-12 14:37:40 字数 2167 浏览 4 评论 0原文

我在尝试编译一些自定义库的 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,但它也不喜欢通配符。

谢谢! 戴夫

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

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

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

发布评论

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

评论(1

浅暮の光 2024-09-19 14:37:41

我有类似的问题。在 任务之前试试这个

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文