Skip to content

HTML logger sometimes shows error when using multiple vstest runner in parallel #15404

Description

@informatorius

VSTest version 17.14.0 (x64)

When using multiple vstest runner in parallel and using html logger then sometimes it shows error about xml file already ins use.

I run vstest in parallel processes

vstest.console MyUnitTestDll1.dll --logger:console;verbosity=quiet --logger:html;LogFileName=DotnetTestLog1.html --logger:trx;LogfileName=DotnetTestLog1.trx

vstest.console MyUnitTestDll2.dll --logger:console;verbosity=quiet --logger:html;LogFileName=DotnetTestLog2.html --logger:trx;LogfileName=DotnetTestLog2.trx

vstest.console ...


When one process finishes it seems to have a temporary xml result file: "TestResult_USERNAME_MACHINENAME_DATETIMESTAMP.xml"

If two processes finish in the same second then they try to use the same xml file. Because the temporary filename date time stamp is only accurate by seconds. That leads to access violation file is already used by another process.

Current Result: The html file is not created from xml file
Expected Result: The html file is created from xml file

Activity

  1. MihuBot commented on Feb 17, 2026

    @MihuBot

    I'm a bot. Here is a possible duplicate issue (I may be wrong):

  2. informatorius commented on Feb 17, 2026

    @informatorius
    Author

    Solutions could be:

    1. have a mutex lock on the temporary xml file
    2. add additional postfix to temporary xml file name like process id
    3. use a guid for the temporary xml file name.

    https://github.com/microsoft/vstest/blob/90ee608c51f07da7e6b7988b693d5e1a9d33f7a5/src/Microsoft.TestPlatform.Extensions.HtmlLogger/HtmlLogger.cs

    Image

    If running multiple processes the line 353 lock (FileCreateLockObject) will not hold.
    And so multiple processes can pass line 355 if (!File.Exists(fullFilePath)) concurrently.
    So multiple processes successfully pass line 357 using var _ = File.Create(fullFilePath)
    where 1st process creates the file and 2nd process overwrites the same file
    => this is the error scenario

  3. added 2 commits that reference this issue on Mar 24, 2026
    dfc57b2
    62aa82c
  4. added a commit that references this issue on Mar 24, 2026
    a18c01f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions