MSBuild 转换不评估通配符
我在尝试编译一些自定义库的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有类似的问题。在
任务之前试试这个不幸的是,文档说
CreateItem
任务已被弃用,所以我不知道将来如何解决这个问题。I had a similar problem. Try this, just before the
<Copy>
taskUnfortunately the documentation says
CreateItem
task is deprecated, so I don't know how to solve tis problem in the future.