Closed ShipraRay150 closed 1 year ago
Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!
@yazeedobaid In Azure devops pipeline my build is failing(Agent Specification : windows-2019 selected), before the solution was building fine when agent specification selected as vs2017-windows2016 AzureDevopsPipelineError.txt
And in Fake build script (Fake.DotNet.MSBuild.run)at this line it is failing:
let Compile(solutionFile: string) (configuration: string) = !! solutionFile |> Fake.DotNet.MSBuild.run id buildDir "Clean,Build" [("Configuration", configuration); ("PlatformTarget", "AnyCpu"); ("Verbosity", "Diagnostic")] |> Trace.logItems ("Compile-Output "+solutionFile+": ")
@yazeedobaid
In pipelines i am not adding any MSBuild path. When agent specification selected as windows-2019 it should pick the current MSBuild path
@yazeedobaid Please help on this.
@ShipraRay150 can u please add a log statement to your Azure pipeline to output the path to MSBuild and share it so that I can debug why FAKE is failing to find that path?
@yazeedobaid Below is the AzureDevops Pipeline logs for MSBuild path: 2022-08-30T08:02:07.8182988Z Starting task 'MSBuild': D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln 2022-08-30T08:02:07.8711593Z Building project: D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln 2022-08-30T08:02:07.8712600Z c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln "/t:Clean,Build" "/m" "/nodeReuse:False"
When i am selecting Agent-Specification: windows-2019 MSBuild path taken as : c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
When i was using Agent Specification as win16-VS2017(which is now deprecated by Microsoft): when the build.fsx was successful
AzureDevops Pipeline Logs: 2021-11-24T05:32:39.1476840Z Starting task 'MSBuild': D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln 2021-11-24T05:32:39.1815228Z Building project: D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln 2021-11-24T05:32:39.1817175Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln "/t:Clean,Build" "/m" "/nodeReuse:False" "/p:RestorePackages=False" "/p:OutputPath=D:\a\1\s\build\" "/p:Configuration=Debug" "/p:PlatformTarget=AnyCpu" "/p:Verbosity=Diagnostic" 2021-11-24T05:32:39.2391327Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe D:\a\1\s\source\ING.myLeo.Common\ING.myLeo.Common.sln "/t:Clean,Build" "/m" "/nodeReuse:False" "/p:RestorePackages=False" "/p:OutputPath=D:\a\1\s\build\" "/p:Configuration=Debug" "/p:PlatformTarget=AnyCpu" "/p:Verbosity=Diagnostic" 2021-11-24T05:32:39.7761138Z Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework 2021-11-24T05:32:39.7762156Z Copyright (C) Microsoft Corporation. All rights reserved.
MSBuild path was: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
@yazeedobaid I have added below line in my build.fsx script to set the default msbuiltpath but it is not working: let msBuildPath ="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
let setParams defaults = { defaults with Verbosity = Some(Quiet) ToolsVersion = Some(toolsVersion) ToolPath = msBuildPath Targets = ["Build"] Properties = [ "Optimize", "True" "DebugSymbols", "True" "Configuration", buildMode ] }
For some reason fake.build is still taking the below MSBuild path: c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
@ShipraRay150 , Thanks for providing the repro sample, I tried your sample locally and it worked, it picked the path that I'm providing as follows:
let msBuildPath = @"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
let setParams defaults = { defaults with ToolPath = msBuildPath; Targets = ["Build"] }
MSBuild.run setParams "\\build" "Clean,Build" [("Configuration", "Release"); ("PlatformTarget", "AnyCpu"); ("Verbosity", "Diagnostic")] ["myproject.sln"]
Here I have provided the path for Visual Studio V2022, notice that I provided the myproject.sln
in projects list to make step fail and debugged the called command of MSBuild, and following is the result from executing the script:
Starting task 'MSBuild': myproject.sln
> "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" /version /nologo (In: false, Out: true, Err: true)
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe myproject.sln /t:Build;Clean,Build /m /nodeReuse:False /p:RestorePackages=False /p:OutputPath=C:%5Cbuild%5C /p:Configuration=Release /p:PlatformTarget=AnyCpu /p:Verbosity=Diagnostic "/bl:C:\Users\YazeedObaid\AppData\Local\Temp\tmp77E7.tmp.binlog"
C:\Users\YazeedObaid\Desktop\fake> "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" myproject.sln /t:Build;Clean,Build /m /nodeReuse:False /p:RestorePackages=False /p:OutputPath=C:%5Cbuild%5C /p:Configuration=Release /p:PlatformTarget=AnyCpu /p:Verbosity=Diagnostic "/bl:C:\Users\YazeedObaid\AppData\Local\Temp\tmp77E7.tmp.binlog" (In: false, Out: false, Err: false)
Also, if I corrupted the path, like so C:\Program Filesssss\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe
I got the following result, which now picks the in-correct path:
Starting task 'MSBuild': myproject.sln
> "C:\Program Filesssss\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" /version /nologo (In: false, Out: true, Err: true)
Could not detect msbuild version from 'C:\Program Filesssss\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe': System.Exception: Start of process 'C:\Program Filesssss\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe' failed.
In your sample, you are providing more options:
let setParams defaults =
{ defaults with
Verbosity = Some(Quiet)
ToolsVersion = Some(toolsVersion)
ToolPath = msBuildPath
Targets = ["Build"]
Properties =
[
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", buildMode
]
}
Can you try with the minimum options provided and see the results? For example, you are providing a value for ToolsVersion, what value are you providing and can you try without it?
@ShipraRay150 any updates on this?
closing this due to inactivity, please feel free to re-open.
How can i set build.fsx to pick VS2019 MSBuild toolversion
Repro steps In my local machine i have VS2019 where the soln.fsx file is building fine(I have set the MSBuild environment path as 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin')
But in Azure Devops pipeline it is failing, i am selecting Agent Specification as windows-2019
Expected behavior In my sln.fsx file below line:
Fake.DotNet.MSBuild.run is not picking the current VS2019 MSBuild
Actual behavior How can i make the change in soln.fsx file to pick the VS2019 MSBuild ? so that in Azure Devops pipeline mu build scripts pass when selecting agent windows-2019 (Before we were using agent specification-vs2017-win2016', when the build was successfull but microsoft have deprecated this agent from 2022 onwards). Please help!
Operating system - Windows 10
Version of FAKE - 5.3.0.0