In another discussion about the location of MSBuild15, If found an example Powershell line that could locate it:
https://help.appveyor.com/discussions/questions/3723-could-build-tools-for-visual-studio-2017-be-installed-to-the-vs-2017-image
$msbuildPath = $(cmd /c where msbuild)
I want to add that path to the PATH environment variable. Isolating just the path would look like this in powershell:
$msbuildPath = $(cmd /c where msbuild).Substring(0,$var.IndexOf("MSBuild.exe"))
But I'm not sure what the best way to get that dynamically discovered path to be added to the PATH environment variable. Under install: there's a set command I can use to set the PATH environment variable, but that's outside the context of any powershell script I'd run before that.
What's the right way to do this?
Thanks!

#1 Posted by Ilya Finkelshte... on 12 Sep, 2018 11:41 PM
Why would you do this? I did not test your command, but if
where msbuildworks, this means that exactly the same path already in thePATHenvironment variable. Otherwisewhere msbuildwould not work...What is bigger problem you are solving?
#2 Posted by BobbyA on 13 Sep, 2018 01:48 PM
Ha, wonderful You're right. I've been tasked with updating an existing repo to verify it's compatible with Visual Studio 2017, and my appveyor builds started breaking when I updated:
os: Visual Studio 2015
to
os: Visual Studio 2017
because it was using MSBuild 14.0. The appveyor.yml file had this script happening during the install phase:
install:
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
So I was trying to update that line, but it didn't occur to me to check if we really needed that line (or that Feodor's line from the other question wouldn't work if MSBuild's directoery wasn't already in the path)
Thanks!
#3 Posted by Ilya Finkelshte... on 13 Sep, 2018 01:50 PM
Good, thanks for the update :)
Ilya Finkelshteyn closed this discussion on 13 Sep, 2018 01:50 PM.