2
votes

I am building a solution with MSBuild on different workstations. For instance on a workstation on which Visual Studio 2017 is installed with a Platform version 10.017763.0, I do:

msbuild solution.sln /p:Configuration=Release /p:Platform=x64 /p:TargetPlatformVersion=10.0.17763.0

On other nodes, this target is not available. So How can I tell MSBUILD to use the most recent target platform version if several are available?

In advance, thanks for your constructive inputs.

1

1 Answers

3
votes

You could venture out and use the following (undocumented) function to get the latest supported version:

<PropertyGroup>
  <LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
  <TargetPlatformVersion Condition="'$(TargetPlatformVersion)' == ''">$(LatestTargetPlatformVersion)</TargetPlatformVersion>
</PropertyGroup>

See here and here for more context and also the source of the above snippet.

However: You might think again and consider using that at all. Because, this way you have practically no reliable builds, depending on which node you build on you're using different settings (uncontrolled even). You probably should rather either choose the smallest commen version to all nodes, or upgrade the other ones. That way, regardless of where you build, you can be sure you are using the same (build) tools and get the same build result.