MSBuild RecursiveDir为空 [英] MSBuild RecursiveDir is empty
问题描述
< Project xmlns = http://schemas.microsoft.com/developer/msbuild/2003\">
< PropertyGroup>
< SourceHome Condition ='$(SourceHome)'==''> .. \< / SourceHome>
< ToolsHome Condition ='$(ToolsHome)'==''> .\Tools\< / ToolsHome>
< Configuration Condition ='$(Configuration)'==''>发布< / Configuration>
< DestFolder Condition ='$(DestFolder)'==''> .\ $(Configuration)\< / DestFolder>
< / PropertyGroup>
< ItemGroup>
< AllSolutions Include =$(SourceHome)** \ * .sln/>
< / ItemGroup>
< Target Name =DefaultDependsOnTargets =Clean; Build; Assemble/>
< Target Name =Clean>
< Message Text =清洁项目.../>
< MSBuild Projects =@(AllSolutions)
Targets =Clean
Properties =Configuration = $(Configuration);/&
< / Target>
< Target Name =RestorePackages>
< Message Text =恢复软件包.../>
< Exec Command =echo y |& quot; $(ToolsHome)NuGet \NuGet.exe& quot; restore& quot;%(AllSolutions.Identity)& quot;
< / Target>
< Target Name =BuildDependsOnTargets =RestorePackages>
< Message Text =构建项目.../>
< MSBuild Projects =@(AllSolutions)
ContinueOnError =true
Properties =Configuration = $(Configuration)>
< Output ItemName =OutputFilesTaskParameter =TargetOutputs/>
< / MSBuild>
< / Target>
< Target Name =Assemble>
< Message Text =Assembling output .../>
< RemoveDir Directories =$(DestFolder)/>
< Copy SourceFiles =@(OutputFiles)
DestinationFiles =@(OutputFiles->'$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)')/> ;
< / Target>
< / Project>
脚本运行良好,除了最后一个复制任务,其中%(RecursiveDir)评估为空字符串,
我发现了 MSBuild ITaskItem RecursiveDir元数据消失,但似乎不适用这里...
我还发现此和这个线程,但在任何路径中没有双斜杠或大括号。下面是复制任务期间输出的示例:
从
复制文件x:\my\repo\\ \\ SolutionDir \ProjectDir\bin\Release\Example.dll到
.\Release\Example.dll。
即使 AllSolutions
项目具有由于您的代码中的 **
通配符填充的RecursiveDir元数据, MSBuild任务未填充 RecursiveDir
在 OutputFiles
项目。 TargetOutputs
放置在一个具有完整路径但没有 RecursiveDir
元数据的单个数组中。
I'm trying to make a custom MSBuild script to build all solutions in our repository:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SourceHome Condition=" '$(SourceHome)'=='' ">..\</SourceHome>
<ToolsHome Condition=" '$(ToolsHome)'=='' ">.\Tools\</ToolsHome>
<Configuration Condition=" '$(Configuration)'=='' ">Release</Configuration>
<DestFolder Condition=" '$(DestFolder)'=='' ">.\$(Configuration)\</DestFolder>
</PropertyGroup>
<ItemGroup>
<AllSolutions Include="$(SourceHome)**\*.sln"/>
</ItemGroup>
<Target Name="Default" DependsOnTargets="Clean;Build;Assemble"/>
<Target Name="Clean">
<Message Text="Cleaning projects..."/>
<MSBuild Projects="@(AllSolutions)"
Targets="Clean"
Properties="Configuration=$(Configuration);"/>
</Target>
<Target Name="RestorePackages">
<Message Text="Restoring packages..."/>
<Exec Command="echo y| "$(ToolsHome)NuGet\NuGet.exe" restore "%(AllSolutions.Identity)""/>
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages">
<Message Text="Building projects..."/>
<MSBuild Projects="@(AllSolutions)"
ContinueOnError="true"
Properties="Configuration=$(Configuration)">
<Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>
</MSBuild>
</Target>
<Target Name="Assemble">
<Message Text="Assembling output..."/>
<RemoveDir Directories="$(DestFolder)"/>
<Copy SourceFiles="@(OutputFiles)"
DestinationFiles="@(OutputFiles->'$(DestFolder)%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>
</Project>
The script works well except for the last copy task where %(RecursiveDir) evaluates to an empty string, putting all files in the root destination folder... I can't see what I'm doing wrong here.
I found MSBuild ITaskItem RecursiveDir metadata disappears but it doesn't seem to apply here...
I also found this and this thread but there are no double slashes or braces in any paths. Heres an example of the output during the copy task:
Copying file from "x:\my\repo\SolutionDir\ProjectDir\bin\Release\Example.dll" to ".\Release\Example.dll".
Even though the AllSolutions
items have RecursiveDir metadata populated because of the **
wildcard in your code, the MSBuild task is not populating RecursiveDir
in the OutputFiles
items. The TargetOutputs
are placed into a single array, with full paths but no RecursiveDir
metadata.
这篇关于MSBuild RecursiveDir为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!