The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable program

I’m trying to setup the trx2junit in circleci but can’t get it to work, so far my relevant code is:

# ...

- run:
     name: "Run Application Tests"
     command: dotnet test --no-build --logger "trx" --results-directory tests/output
 - run:
    name: "Collect Test Results"
     when: always
     command: |
        dotnet tool install -g trx2junit
        trx2junit tests/output/*.trx --output tests/TestResults

Error from circleci:

 Since you just installed the .NET SDK, you will need to reopen the Command Prompt window before running the tool       you installed.
 You can invoke the tool using the following command: trx2junit
 Tool 'trx2junit' (version '2.0.0') was successfully installed.
 trx2junit : The term 'trx2junit' is not recognized as the name of a cmdlet, function, script file, or operable 
 program. Check the spelling of the name, or if a path was included, verify that the path is correct and try  again.
 At line:3 char:1

This only happens with a branch we’re preparing with .NET 6 in our build pipelines. We’re using the recommended executor for .NET 6:
executor:
imagename: windows-server-2022-gui
name: win/windows
size: medium
version: edge

Our other branches that use the win/default executor image (.NET 5)the following code works without a problem:

 - run:
     name: "Collect Test Results"
     when: always
     command: |
        dotnet tool install -g trx2junit
        trx2junit tests/output/*.trx --output tests/TestResults

I’ve also posted in the GitHub of trx2junit but this seems more related to circle ci:

@capalmeida please try the new edge image. Apparently this is a Microsoft issue. After installing a new tool regardless if it is right after installing the SDK you need to open a new windows for it to be available in the path.

Here is a workaround that I use:

Here is an article discussing the issue:

Please let me know if you have further issues

Thanks!
Michael Rothstein

1 Like