我已经困扰很久了。
背景:
- c# project
- c++ project
c# project has a reference for the c++ project with the following lines:
<ProjectReference Include="projectB.vcxproj"> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> <OutputItemType>Content</OutputItemType> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </ProjectReference>
这在Visual Studio中可以工作。 使用命令行中的devenv时可以工作。 但是,当使用命令行中的msbuild时,C++项目的输出文件未复制到C#项目的输出目录中。
我无法使用msbuild解决这个问题。阅读了很多相关资料,但没有一个有效的方法。尝试通过诊断详细信息来进行调试,但msbuild和visual-studio的日志格式非常不同... 由于构建机器上没有合法的Visual Studio,我不能使用devenv。
在msbuild日志中,使用诊断详细信息显示:
Target "GetCopyToOutputDirectoryItems" skipped. Previously built successfully.
在Visual Studio日志中,此处看起来不同,并且实际上复制了引用的本地文件到C#输出目录中。
可能与构建顺序有关?..
在msbuild日志中,我还看到:
Target "_CopyOutOfDateSourceItemsToOutputDirectoryAlways" skipped, due to false condition; ( '@(_SourceItemsToCopyToOutputDirectoryAlways)' != '' ) was evaluated as ( '' != '' ).
而在Visual Studio构建日志中,我看到此目标被执行(它紧随GetCopyToOutputDirectoryItems目标之后)。
BuiltProjectOutputGroup
目标有文档吗? - yair