我试图制作一个自定义MSBuild脚本来在我们的存储库中构建所有解决方案:
<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>
该脚本运行良好,除了最后一个复制任务,其中%(RecursiveDir)计算为空字符串,将所有文件放在根目标文件夹中...我无法看到我做错了什么这里。
我找到了MSBuild ITaskItem RecursiveDir metadata disappears,但它似乎并不适用于此......
我还发现了this和this线程,但在任何路径中都没有双斜线或大括号。下面是复制任务期间输出的示例:
从中复制文件 &#34; X:\我的\回购\ SolutionDir \ PROJECTDIR \ BIN \发布\ Example.dll&#34;至 &#34; \发布\ Example.dll&#34;
答案 0 :(得分:1)
即使AllSolutions
项由于代码中的**
通配符填充了RecursiveDir metadata,MSBuild task也没有填充RecursiveDir
OutputFiles
1}}项目。 TargetOutputs
被放置在一个数组中,包含完整路径但没有RecursiveDir
元数据。