![](/img/trans.png)
[英]Visual Studio 2019 not copying changed and compiled dll to startup project's bin folder in x64 target
[英]Rules for Custom build's <Outputs> tag check for directories changed in Visual Studio 2019?
让我们把晦涩的问题变得简单......
我们有一个由许多项目组成的解决方案,其中一些项目使用 3rd 方的东西设置了自定义构建事件,用于一些黑暗魔法编译,看起来像这样:
<CustomBuild Include="..\folder\somestuff.xyz">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">C:\Tcl\bin\tclsh.exe $(APP_PATH)\modules\APP\bin\generator.tcl -o %(RelativeDir)%(Filename) %(RelativeDir)%(Filename).xyz</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">APPGEN %(RelativeDir)%(Filename)</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)%(Outputs)</Outputs>
</CustomBuild>
这一直正常工作,直到我们从 VS2015 切换到 VS2019,因为现在在编译期间它报告说: Project is not up-to-date: build output 'd:\projects\program\app\src\plugins\shared\' is missing
. 这或多或少没问题,但它迫使编译器也重新编译这个项目的依赖项,这开始真的很烦人,因为即使没有进行任何更改,每次都需要重建几个项目。
我发现问题出在这行自定义构建:
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)%(Outputs)</Outputs>
从这部分更准确地说: %(RelativeDir)%(Outputs)作为在同一标记中检查.cpp和.h文件不会产生任何问题。 所以我删除了这个目录检查。 删除这段代码后,项目会正确编译,并且不会整天重新编译。
那么为什么自定义版本的 Output 检查现在可以正常工作,只是文件和目录会产生这种问题?
是的,检查的目录存在,它指的是现有的正确路径。
真正的问题是,由于元数据Outputs
,您的真实项目总是在重建。
特别的一点是,你应该确保Outputs
的值的有效性和合法性。
问题在%(RelativeDir)
%(RelativeDir)%(Outputs)
的 %(RelativeDir) 之下。 添加它时, outputs
具有非法文件夹结构而不是文件,这使得outputs
始终找到丢失的非法文件夹结构,从而导致项目始终重建。
让我详细描述一下,
当 msbuild 读取outputs
属性时,当它读取到%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)
时, Outputs
的值是这样的:
..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\
然后,它读取%(Outputs)
(读取自身),这更像是将上述值复制两次:
..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\
你会发现最后一部分..\folder\
不是一个文件,它是一个文件夹结构,对于outputs
来说是非法的。
这就是原因。
它更像是您的问题,文件夹结构d:\projects\program\app\src\plugins\shared\
丢失。
建议
所以你不应该再次添加outputs
。
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;</Outputs>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.