Home > Posts > Fix: Delphi error MSBuildToolsPath is not specified for the ToolsVersion …

Fix: Delphi error MSBuildToolsPath is not specified for the ToolsVersion …

This is my answer at:

http://stackoverflow.com/questions/32936544/delphi-10-seattle-trial-fails-to-compile-anything-gives-an-msbuild-error

for the issue of Delphi showing on build the error

MSBuildToolsPath is not specified for the ToolsVersion “12.0” defined at “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0”, or the value specified evaluated to the empty string

note that in my case it was also showing underlined unit names in the code editor at uses clause with “Cannot resolve unit name xx”


It is a known issue, documented here: https://community.embarcadero.com/article/technical-articles/16202-msbuildtoolspath-is-not-specified-for-the-toolsversion

This error is caused by incorrect values in the registry. On a 32 OS, run regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild. On a 64 bit OS, run regedit and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild. First, backup this registry key by selecting File | Export. Next, look at the numbers below the ToolsVersions key. Delete any number not found at the MSBuild level. … There is anecdotal evidence to suggest this registry key imbalance is caused by uninstalling some versions of Visual Studio, but it has not been confirmed at this time.

Since I’ve been installing/uninstalling various Visual Studio versions (including previews), guess it has indeed been caused by that

Error “A default tools version “2.0” was specified, but its definition could not be found.” may appear then if you deleted the 2.0 key following the 1st article’s advice. Solution for that one is to edit each value under MSBuild key in the registry locations mentioned for x32 and x64 and change DefaultToolsVersion to 14.0 or other highest MSBuild tools version that is installed

Στιγμιότυπο οθόνης (504)

image

Note that on x64 machine you need to fix these two issues for both x32 and x64 registry locations, since the IDE is 32-bit process and if you fix x64 location only it will fail internally, underlining all Standard units at uses clause in your source code at uses clause and showing “Cannot resolve unit name xx”

Στιγμιότυπο οθόνης (506)

image

Also it may be useful to install this: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48159

This may also be useful to know (copying from https://msdn.microsoft.com/en-us/library/bb383985.aspx):

Order of Precedence

The order of precedence, from highest to lowest, used to determine the ToolsVersion is: The ToolsVersion attribute on the MSBuild task used to build the project, if any.

The /toolsversion (or /tv) switch that’s used in the msbuild.exe command, if any.

If the environment variable MSBUILDTREATALLTOOLSVERSIONSASCURRENT is set, then use the current ToolsVersion.

If the environment variable MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT is set and the ToolsVersion defined in the project file is greater than the current ToolsVersion, use the current ToolsVersion.

If the environment variable MSBUILDLEGACYDEFAULTTOOLSVERSION is set, or if ToolsVersion is not set, then the following steps are used:

The ToolsVersion attribute of the Project element of the project file. If this attribute doesn’t exist, it is assumed to be the current version.

The default tools version in the MSBuild.exe.config file.

The default tools version in the registry. For more information, see Standard and Custom Toolset Configurations.

If the environment variable MSBUILDLEGACYDEFAULTTOOLSVERSION is not set, then the following steps are used:

If the environment variable MSBUILDDEFAULTTOOLSVERSION is set to a ToolsVersion that exists, use it.

If DefaultOverrideToolsVersion is set in MSBuild.exe.config, use it.

If DefaultOverrideToolsVersion is set in the registry, use it.

Otherwise, use the current ToolsVersion.

Categories: Posts Tags: , , , ,
  1. 2018/11/29 at 12:30

    thanks for article, this is very helpfull!!
    after installing this “Also it may be useful to install this: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48159” i have solve the problem!
    thanks alot!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: