C# – Task could not find “LC.exe” using SdkToolsPath

ctfsvisual-studio-2013

I have cloned a project to my computer using TFS, when I build the project I get this error :

Error 6 Task could not find "LC.exe" using the SdkToolsPath "" or the
registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v8.1A\WinSDK-NetFx40Tools-x86". Make sure the
SdkToolsPath is set and the tool exists in the correct processor
specific location under the SdkToolsPath and that the Microsoft
Windows SDK is installed

I have searched the web but couldn't find a solution. I use VS 2013 and .NET 4.
How can I fix this? Thanks.

Best Answer

It turns out you can specify the path to the SDK directly in the .csproj file:

<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools</TargetFrameworkSDKToolsDirectory>

and the build found lc.exe that way. So do a dir /s for lc.exe and use that path.

I previously expected to set this using <SdkToolsPath>, but that didn't work. In Microsoft.Common.targets, SdkToolsPath gets set from TargetFrameworkSDKToolsDirectory, so I tried that and it worked. (It would be nice if the variable name corresponded 1 to 1, but they don't.)

This is on Visual Studio 2015, and msbuild being called from ant.

Related Topic