[英]Rules for Custom build's <Outputs> tag check for directories changed in Visual Studio 2019?
Lets make obscure question simple...让我们把晦涩的问题变得简单......
We have a solution which consists of many projects and some of them have set Custom build events using 3rd party stuff for some dark magic compilation and looks similar like this:我们有一个由许多项目组成的解决方案,其中一些项目使用 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>
This was working properly until we switch form VS2015 to VS2019 as now during the compilation it reports that: Project is not up-to-date: build output 'd:\projects\program\app\src\plugins\shared\' is missing
.这一直正常工作,直到我们从 VS2015 切换到 VS2019,因为现在在编译期间它报告说:
Project is not up-to-date: build output 'd:\projects\program\app\src\plugins\shared\' is missing
. This would be more or less ok, but it forces the compiler to recompile also the dependencies of this project and this start to be really annoying as you need to rebuild several projects everytime even when no changes were done.这或多或少没问题,但它迫使编译器也重新编译这个项目的依赖项,这开始真的很烦人,因为即使没有进行任何更改,每次都需要重建几个项目。
I found out that the problem originates from this line of Custom build:我发现问题出在这行自定义构建:
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)%(Outputs)</Outputs>
More precisely from this part: %(RelativeDir)%(Outputs) as the check for .cpp and .h file in the same tag do not generate any issues.从这部分更准确地说: %(RelativeDir)%(Outputs)作为在同一标记中检查.cpp和.h文件不会产生任何问题。 So I removed this check for directory.
所以我删除了这个目录检查。 When this chunk of code is removed the project compiles properly and do not re-compile all day long.
删除这段代码后,项目会正确编译,并且不会整天重新编译。
So why the Custom build's Output check is now working properly just with files and directories are generating this kind of issue?那么为什么自定义版本的 Output 检查现在可以正常工作,只是文件和目录会产生这种问题?
And yes, the examined dir exists and it refers to the existing correct path.是的,检查的目录存在,它指的是现有的正确路径。
The real problem is that your real project is always rebuild due to the metadata Outputs
.真正的问题是,由于元数据
Outputs
,您的真实项目总是在重建。
The special point is that you should make sure the validity and legitimacy of the value of Outputs
.特别的一点是,你应该确保
Outputs
的值的有效性和合法性。
The problem is under %(RelativeDir)
of %(RelativeDir)%(Outputs)
.问题在
%(RelativeDir)
%(RelativeDir)%(Outputs)
的 %(RelativeDir) 之下。 When you add it, the outputs
has an illegal folder structure rather than a file which makes the outputs
always find the missing illegal folder structure so that causes the project always rebuild.添加它时,
outputs
具有非法文件夹结构而不是文件,这使得outputs
始终找到丢失的非法文件夹结构,从而导致项目始终重建。
Let me describe it in detail,让我详细描述一下,
when msbuild reads outputs
proeperty, when it reads till %(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)
, the value of Outputs
is this:当 msbuild 读取
outputs
属性时,当它读取到%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;%(RelativeDir)
时, Outputs
的值是这样的:
..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\
Then , it reads %(Outputs)
(reads itself), which is more like copy the above value twice:然后,它读取
%(Outputs)
(读取自身),这更像是将上述值复制两次:
..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\
You will find the last part ..\folder\
is not a file and it is a folder structure which is illegal for the outputs
.你会发现最后一部分
..\folder\
不是一个文件,它是一个文件夹结构,对于outputs
来说是非法的。
That is the reason.这就是原因。
And it is more like your problem that the folder structure d:\projects\program\app\src\plugins\shared\
is missing.它更像是您的问题,文件夹结构
d:\projects\program\app\src\plugins\shared\
丢失。
Suggestion建议
So you should not add outputs
again.所以你不应该再次添加
outputs
。
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;</Outputs>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.