fsprojects / FAKE

FAKE - F# Make
https://fake.build
Other
1.28k stars 582 forks source link

How can i set build.fsx to pick VS2019 MSBuild toolversion #2697

Closed ShipraRay closed 1 year ago

ShipraRay commented 1 year ago

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!

github-actions[bot] commented 1 year ago

Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project!

yazeedobaid commented 1 year ago

Thanks for reporting, so you know the path to MSBuild on the Azure pipeline but the MSBuild task from FAKE is not picking up that path? If that is the case, could you please provide the path you know so that we can debug it more? And as a workaround, can you try one of these options:

  1. Try to set the MSBuild tool location from the AppSettings file using a parameter named MSBuild
  2. Specify the VisualStudioVersion environment variable, MSBuild task in FAKE try to use the specific MSBuild version, matching that Visual Studio version.

Also, the paths that FAKE search for are specified here

ShipraRay commented 1 year ago

In Local machine i have VS2019 installed, and in environment variable i have added MSBuild path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin

And i am able to build the solution.

But in Azure devops pipeline my build is failing(Agent Specification : windows-2019 selected)

ShipraRay commented 1 year ago

In my build.fsx file added this to forcibly take VS 2019 version but still it didnot worked:

let toolsVersion = "Current"

let setParams defaults = { defaults with Verbosity = Some(Quiet) ToolsVersion = Some(toolsVersion) Targets = ["Build"] Properties = [ "Optimize", "True" "DebugSymbols", "True" "Configuration", buildMode ] }

Need some help to fix the pipeline build issue!

yazeedobaid commented 1 year ago

Could you please share a complete build script that has the issue, the error message you get from Azure Pipeline, and the path to MSBuild in Azure Pipeline that FAKE is failing to find?

yazeedobaid commented 1 year ago

Closing this issue since it is a duplicate of #2703