简体   繁体   中英

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:

<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 . 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. 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?

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 .

The special point is that you should make sure the validity and legitimacy of the value of Outputs .

The problem is under %(RelativeDir) of %(RelativeDir)%(Outputs) . 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.

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:

..\folder\somestuff.cpp;..\folder\somestuff.h;..\folder\

Then , it reads %(Outputs) (reads itself), which is more like copy the above value twice:

..\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 .

That is the reason.

And it is more like your problem that the folder structure d:\projects\program\app\src\plugins\shared\ is missing.

Suggestion

So you should not add outputs again.

<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(RelativeDir)%(Filename).cpp;%(RelativeDir)%(Filename).h;</Outputs>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM