Team,
I have a powershell script that invokes MSBUILD.exe to run the build in Azure devops Build pipeline for packaging it. Currently script uses vs12. I ran into below error when it ran with vs 12.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
So on one of my collegue's suggesstion, i had to change it from vs 12 to vs 15 and hard coded the below path for MSBUILD.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\
And the build runs fine. So now, i'd like to use ENV for this path in my powershell script so that it picks it up dynamically.
Below is the function that runs MS build.
Function Get-MSBuild {
$lib = [System.Runtime.InteropServices.RuntimeEnvironment]
$rtd = $lib::GetRuntimeDirectory()
Join-Path $rtd msbuild.exe}
Above code fails on my agent, and i run into file exists on disk error. and i replaced the $lib with msbuild path. as below.
Function Get-MSBuild {
$lib = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\"
Join-Path $lib msbuild.exe
}
Above code works fine, but i want to generate the path dynamically using an env or some predefined environment variable.
Now, my question is is there a predefined environment variable to dynamically obtain the path for
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\"
Thanks in advance for help.