2

I have a project in my solution which gets built (consequently all the dependent projects as well) on every run due to the following file missing. I changed the build output verbosity to Diagnostics and got the following line at the top of the build of the said project:

Build started...

1>------ Up-To-Date check: Project: project_name.vcxproj, Configuration: Release x64 ------

1>Project is not up-to-date: build output 'c:\path\appdata\local\temp\lnk{24e28c62-71a7-43ad-81e2-9b34157645b4}.tmp' is missing

1>------ Build started: Project: project_name, Configuration: Release x64 ------

This number (24e28c62-71a7-43ad-81e2-9b34157645b4) changes on every build.

The solutions that I have tried which didn't work:

The rebuild happens when I click the build solution regardless of any changes or lack there of in the code.

Edit:

The linker /VERBOSE output on building the said project:

Build started...
1>------ Build started: Project: project_name, Configuration: Release x64 ------
1>Invoking cvtres.exe:
1> /machine:amd64
1> /verbose
1> /out:"C:\Users\path\AppData\Local\Temp\lnk{01385313-5798-4F09-8223-983424FE6954}.tmp"
1> /readonly
1> "C:\Dev\dev\ws2\build\Release_x64\i\project_name\name-of-dll.res"
1>Microsoft (R) Windows Resource To Object Converter Version 14.30.30711.1
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>
1>adding resource. type:VERSION, name:1, language:0x0407, flags:0x30, size:576
  • Are the dates of any of the files in the project that gets rebuilt in the future? – drescherjm Nov 22 '22 at 17:08
  • 1
    https://developercommunity.visualstudio.com/t/linkexe-files-stored-in-tmp-needed-for-up-to-date/1363030 – Hans Passant Nov 22 '22 at 19:07
  • According to the link provided by Hans, you need to manually confirm this problem. If the problem still cannot be solved, I suggest you go to [DC](https://developercommunity.visualstudio.com/report?space=8&entry=problem) to re-report the problem. – Yujian Yao - MSFT Nov 23 '22 at 06:48
  • @HansPassant Thanks for the link. I will put /verbose in the linker to see why the tmp file is not generated. – user19254034 Nov 23 '22 at 07:48
  • 1
    @HansPassant I can see the tmp file in the linker verbose output but I can't see it being created in the temp folder. – user19254034 Nov 23 '22 at 08:16
  • If you have verified that the path is correct then you need to find out why the file won't be created. Top of the hit parade for such problems is file system corruption, run chkdsk to check the disk. At number #2 is anti-malware, temporarily disable it. – Hans Passant Nov 23 '22 at 10:49
  • @HansPassant I found the latest VS update was building one file on every build. Issue got fixed now. Thanks for the hints. – user19254034 Nov 23 '22 at 13:54

2 Answers2

1

You seem to be building a DLL. So this doesn't apply to you. But for others that get this when building a static library, hang on...

Here's a possible cause for rebuilds:

  • Your static library project might contain a resource (*.RC) file.

It's quite odd for a static library to contain a RC file because it could clash with other projects in your solution that consume the static library.

Deleting the .rc and resource.h files can solve the issue (at least it did for me).

The other (top) reason is that your project file points to header files that you have deleted. Since the compiler is not invoked for header files, you won't see errors when building so this is easy to miss!

E. van Putten
  • 615
  • 7
  • 17
  • How did you even manage to track down this insanity... But more importantly, have you found a solution when the `.rc` file is actually used and cannot just be thrown out? – Quentin Jan 03 '23 at 13:28
  • @Quentin our project had a single `.rc` that was really needed, so the rest was deleted. Unfortunately it contained `ICON` resources, which causes additional problems (see of https://stackoverflow.com/questions/31323596/fatal-error-cvt1100-duplicate-resource-typeicon-name1-c-visual-studio-c ) . Had to write a program that converts the icon files to C-array "source code". The data of this array can be converted into an `ICON` resource again at runtime. – E. van Putten Jan 04 '23 at 09:27
  • I basically kept removing things from the project file until it behaved normally. – E. van Putten Jan 04 '23 at 09:28
0

My specific case was the one described by E. van Putten's answer, where Lib screws up when given a .res file as input. More precisely, it ends up writing the path of a temporary file into the .tlog file that is used for its subsequent up-to-date checks (at which point said file is long gone).

Until this is fixed, I've written a crude MSBuild target that is sequenced right after Lib and filters out nonexistent paths from the generated .tlog file.

<!--
This removes the broken temporary file paths that Lib.exe
puts in tlog files when it processes a .rc file.
See https://stackoverflow.com/q/74536502/3233393.
-->
<Target
    Name="BugfixTempFilesInLibTlogs"
    AfterTargets="Lib"
    Condition="Exists('$(TLogLocation)Lib-link-cvtres.write.1.tlog')"
>
    <ReadLinesFromFile
        File="$(TLogLocation)Lib-link-cvtres.write.1.tlog"
    >
        <Output TaskParameter="Lines" ItemName="_LibWriteTlogLines" />
    </ReadLinesFromFile>

    <!--
    Insane item juggling because MSBuild blows up as soon as one mentions `%(FullPath)`
    for something that is not actually a path, such as the first line
    from the .tlog file (which is of the form `^<file>|</file>|...`)
    -->
    <ItemGroup>
        <_LibWriteTlogLinesToRemove Include="@(_LibWriteTlogLines)" />
        <_LibWriteTlogLinesToRemove
            Remove="@(_LibWriteTlogLinesToRemove)"
            Condition="$([System.String]::new('%(Identity)').StartsWith('^'))"
        />
        <_LibWriteTlogLinesToRemove Remove="@(_LibWriteTlogLinesToRemove->Exists())" />
        
        <_LibWriteTlogLines Remove="@(_LibWriteTlogLinesToRemove)" />
    </ItemGroup>
    
    <WriteLinesToFile
        Condition="'@(_LibWriteTlogLinesToRemove)' != ''"
        File="$(TLogLocation)Lib-link-cvtres.write.1.tlog"
        Lines="@(_LibWriteTlogLines)"
        Overwrite="true"
    />
    
    <ItemGroup>
        <_LibWriteTlogLines Remove="@(_LibWriteTlogLines)" />
        <_LibWriteTlogLinesToRemove Remove="@(_LibWriteTlogLinesToRemove)" />
    </ItemGroup>
</Target>

The .tlog file's name seems to change depending on the input to Lib, so make sure that it matches your case.

Quentin
  • 62,093
  • 7
  • 131
  • 191