1

I'm performing code coverage on an application using the Visual Studio 2019 instrumentation tool (VSInstr.exe).

In the command prompt (run as admin), I run "vsinstr.exe -coverage ApplicationName.exe @ExcludeList.txt". The result should be an instrumented .exe and .pdb file with the appropriate libraries and functions excluded, but it always fails with an error: "Unable to backup original file".

The problem is apparently in the excludes list text file, as it runs fine without @ExcludeList.txt. I've looked through the excludes list and made sure none of the exclude statements had any syntax problems. The file is formatted correctly, with no other statements or blank lines, and there are no access restrictions on it.

The executable was built with the Linker profile switch set to 'Yes' (Project => Linker => Advanced => Profile), so it is instrumentable. The .exe, .pdb, and the excludes list text file, ExcludeList.txt, are all in the same directory.

What could be the issue?

dfensdev
  • 13
  • 2
  • Make sure that the directory that contains the .exe and .dlls can be written to. – Hans Passant Jan 30 '23 at 13:00
  • Which version of VS2019 are you using? I recommend you use version 16.6 and above. And this [document](https://stackoverflow.com/questions/4951089/how-to-use-ms-code-coverage-tool-in-command-line) is worth your reference too. – Yujian Yao - MSFT Jan 31 '23 at 09:20
  • @HansPassant the directory isn't set to read only and neither are the .exe and .pdb files. There are no .dlls – dfensdev Jan 31 '23 at 10:39
  • @YujianYao-MSFT I am using version 16.11. For some reason, the instrumentation works when using vsinstr.legacy.exe, not vsinstr.exe. Do you know what the difference is between these? – dfensdev Jan 31 '23 at 10:41
  • hi,vsinstr.legacy.exe is the old version of vsinstr.exe. – Yujian Yao - MSFT Feb 02 '23 at 07:30
  • @YujianYao-MSFT Okay, that seems to work for me but I'd still like to know why it fails when I use the new version. – dfensdev Feb 02 '23 at 08:50

1 Answers1

0

I just used vsinstr.legacy.exe for now - it seems to do the job just as well as the normal one does.

dfensdev
  • 13
  • 2