[BUG] MSBuild.exe (Visual Studio 2019) on Windows-latest is not in system PATH

BUG: MSBuild.exe (Visual Studio 2019) on Windows-latest is not in system PATH

> msbuild src$Env:solutionname -property:Configuration=Debug -m -v:m
msbuild : The term ‘msbuild’ 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 D:\a_temp\9d00f860-8402-433d-a27e-c4564718cff2.ps1:2 char:1

  • msbuild src$Env:solutionname -property:Configuration=Debug -m -v:m
  • CategoryInfo : ObjectNotFound: (msbuild:String) [], ParentContainsErrorRecordException
  • FullyQualifiedErrorId : CommandNotFoundException
    ##[error]Process completed with exit code 1.

https://github.com/ldorau/pmdk/commit/ea64967772ab6a6f2024ba26d8e48ea7893d93b7/checks?check_suite_id=339247591

Thank you for being here! This error is due to msbuild is not added to the path correctly. On Github runner, msbuild is not added into PATH by default.

Add solution for other guys:

  1. add the env path, code as below:

    echo “::add-path::C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin”

  2. or use action ‘warrenbuckley/Setup-MSBuild’ before msbuild command.

1 Like

Visual Studio does not put MSBuild in the path so I don’t think it is appropriate that we do. You should reference MSBuild from its fully qualified location in order to make sure you are running the right version.

2 Likes