我们正在尝试编写一个 msbuild 脚本来构建解决方案并将所有已编译的二进制文件和依赖项复制到特定的输出文件夹。虽然我们拥有的构建脚本确实构建了二进制文件并将其复制到一个公共(public)文件夹,但我们没有复制依赖项。 这可能与我们使用 msbuild 任务构建解决方案的方式有关,我们将任务的目标输出接受到项目组中,并迭代项目组以将所有已编译的 dll 和 exe 复制到一个公共(public)文件夹。但这不包括放置在每个项目的单独 bin 文件夹中的依赖 dll。
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ParentSolutionFile />
</PropertyGroup>
<ItemGroup>
<Assemblies Include="*.dll, *.exe" />
</ItemGroup>
<Target Name="BuildAll">
<CombinePath BasePath="$(MSBuildProjectDirectory)" Paths="Source\Solutions\xxx.sln">
<Output TaskParameter="CombinedPaths" PropertyName="ParentSolutionFile" />
</CombinePath>
<Message Text="$(ParentSolutionFile)" />
<MSBuild Projects="$(ParentSolutionFile)">
<Output TaskParameter="TargetOutputs" ItemName="Assemblies" />
</MSBuild>
<Message Text="%(Assemblies.Identity)" />
<Copy SourceFiles="%(Assemblies.Identity)" DestinationFolder="$(MSBuildProjectDirectory)\Binary" OverwriteReadOnlyFiles="True" SkipUnchangedFiles="True" />
</Target>
将所有二进制文件连同必要的依赖项一起复制到公共(public)输出文件夹的首选方法是什么?
最佳答案
不单独覆盖 OutputPath 就可以解决问题吗?
<MSBuild Projects="$(ParentSolutionFile)" Properties="OutputPath=$(MSBuildProjectDirectory)\Binary">
<Output TaskParameter="TargetOutputs" ItemName="Assemblies" />
</MSBuild>
然后完全忽略复制任务?
关于msbuild - 使用 MSBuild 构建所有输出并将其复制到公共(public)文件夹时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16561119/