简体   繁体   English

自定义构建规则<outputs>标记检查 Visual Studio 2019 中更改的目录?</outputs>

[英]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.

相关问题 Visual Studio 2019 未将更改和编译的 dll 复制到 x64 目标中启动项目的 bin 文件夹 - Visual Studio 2019 not copying changed and compiled dll to startup project's bin folder in x64 target Visual Studio 2019 构建顺序不起作用 - Visual Studio 2019 build order is not working Visual Studio 2019 的离线构建工具 - Offline Build tools for visual studio 2019 为什么Visual Studio 2012在源文件未更改时运行自定义生成步骤? - Why is Visual Studio 2012 running custom build step when source file hasn't been changed? 将警告视为 Visual Studio 2019 中的错误以进行构建但不是智能感知 - Treating warnings as errors in Visual Studio 2019 for build but NOT intellisense 使用“Visual Studio 2019 -&gt; Build”成功构建项目,但使用“MSBuild”失败 - Project successfully built with “Visual Studio 2019 -> Build” but failed with “MSBuild” Visual Studio Online构建服务,git标签 - Visual studio Online build services, git tag Visual Studio 2019 中的工具版本 - ToolsVersion in Visual Studio 2019 我们可以使用在 Visual Studio 2019 中开发的 Visual Studio 2015 构建项目吗 - Can we build a project using Visual Studio 2015 which is developed in Visual Studio 2019 将 Visual Studio 2019 的 MsBuild 与 TFS 2018 任务一起使用 - Using Visual Studio 2019's MsBuild with TFS 2018 task
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM