Error MSB3086: Task could not find "LC.exe" using the SdkToolsPath "" - msbuild

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2428,5):
Error MSB3086: Task could not find "LC.exe" using the SdkToolsPath ""
or the registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft
SDKs\Windows\v8.0A\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 tried to install windows sdk v8.0A. but the installation process was rolling back. I m using os window 10
I am using VS 2017 framework version 4.7

Error MSB3086: Task could not find “LC.exe” using the SdkToolsPath “”
To resolve this issue, please try to following troubleshootings:
Using the MSBuild.exe from Visual Studio 2017 instead of .net framework. The location of MSBuild in Visual Studio 2017 should be:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
Specify the path to the SDK directly in the .csproj file:
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
or pass TargetFrameworkSDKToolsDirectory as a parameter to avoid having to edit your .csproj files
MSBuild.exe mysolution.sln /t:build /p:TargetFrameworkSDKToolsDirectory="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools"
Set a flag to tell MSBuild to ignore it:
/p:GenerateSerializationAssemblies=Off
Try to re-install the Visual Studio 2017.
Hope this helps.

Related

TFS build agent cannot find AXImp.exe

TFS build agent using MSBuild 14.0 fails with "Error MSB3091: Task failed because "AxImp.exe" was not found", while the SDK is installed and AxImp.exe is present.
The error states that it cannot find the file in the bin beneath "the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools-x86"
There is no "Microsoft SDKs" node at that location, however it does exist under Wow6432Node: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\
This node contains references to locations for both WinSDK-NetFx40Tools-x86 and WinSDK-NetFx40Tools-x64.
Is MSBuild looking in the wrong registry location?
Can I configure the build to make it locate either
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools
or
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools\x64
to find AxImp.exe and whatever else it expects from the SDK?
Background:
Our development has so far been built on Windows 10, Visual Studio 2017, targeting .Net Framework 4.6.2. I am now trying to automate builds on Windows Server 2012 R2 Standard.
I have installed Microsoft Build Tools 2015, Microsoft .Net Framework 4.6.2 SDK, .Net Framework 4.6.2 Targeting Pack and .Net Framework 4.6.2 Targeting Pack (ENU).
Have successfully created a build agent and get an almost successful build, after chasing down a number of missing dependencies.
TFS build agent cannot find AXImp.exe
(According to the error messages, they are all common errors. we could not give the most direct correct answer for this issue, we can only give you some troubleshootings. In order to avoid losing contact in the round-trip comments, I post those troubleshootings as answer instead of comments.)
Make sure using the MSBuild task instead of Visual Studio build task in the build definition.
Using MSBuild 14.0 (C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe) rather than 4.0 (C:\Windows\Microsoft.NET\Framework\v4.0.30319) in the MSBuild task, if you build the project with Visual Studio 2015.
Check if the ToolsVersion of the Project node is 14.0 not 4.0:
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Install the Visual Studio 2015 on your build server.
Manually change the above registry key to the correct location, where AXImp.exe exists.
If all above not help you, please share the configuration of MSBuild task definition, the software you have installed on the build agent and try to build the project with Visual Studio 2015 on the build server.
Hope this helps.

Invalid static method invocation syntax: "[MSBuild]::IsRunningFromVisualStudio()"

After upgrading to Visual Studio 2017 15.5 none of my project will load correctly. All are marked unavailable.
I'm getting the following error for every project:
error : Invalid static method invocation syntax: "[MSBuild]::IsRunningFromVisualStudio()". Method '[MSBuild]::IsRunningFromVisualStudio' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
Reloading project produces this error prompt:
Adding new projects produce this error prompt:
1. Close all running instances of Visual Studio 2017
2. Launch (as Administrator) "Developer Command Prompt for VS 2017"
3. Type the following commands (replace Professional with your edition, either Enterprise or Community, or adjust the path accordingly):
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Engine.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Conversion.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll"
gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Build.Utilities.Core.dll"
4. Restart Visual Studio 2017
The solution, provided by henkmollema in this thread: https://github.com/Microsoft/msbuild/issues/2775 was to start the visual studio installer from the start menu and run a repair.
It seems from the responses to this issue on github that it is often caused by having an older version of MSBuild in the GAC. This will then be used in preference to the bundled version that ships with the updated version of VS.
The solution is to remove the old version of Microsoft.Build from the gac.
Find the gac'd versions:
gacutil /l | findstr Microsoft.Build
Look for any of version 15.x.x.x and then remove them:
gacutil /u "Microsoft.Build, Version=15.{version_found}"
Restart Visual Studio
It may also be necessary to remove the related assemblies Microsoft.Build.Utilities.Core, Microsoft.Build.Framework and Microsoft.Build.Tasks.Core of that version.
After installing the latest Visual Studio Version via the Updater, I received the same error messages.
The issue was resolved, at least in my case, by rebooting after installing the Visual Studio update.
Besides the assemblies mentioned in Yuriy Oleynik's answer, I found I need to add an additional assembly (see the last command below) in gac (I'm using VS 2019):
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.Conversion.Core.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.Engine.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.Framework.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.Tasks.Core.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Build.Utilities.Core.dll"
gacutil.exe -i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\System.Collections.Immutable.dll"
I've come accross this problem in vs2019 with Framework Core 3.1. The problem was two fold.
First of all i've updated my VS2019 to the last version, the project was loading, but I got compilation errors.
I've opened C:\Windows\Microsoft.NET\assembly\GAC_MSIL and removed all microsoft.buid.* except Microsoft.Build.Utilities.Core, Microsoft.Build.Utilities.v4.0 and Microsoft.Build.Utilities.v4.0.resources
And all worked
I had this problem with Visual Studio 2017 on a Windows 7 PC on a corporate network. I tried to fix the issue in the following ways:
restarting the computer/Visual Studio several times (as mentioned by an answer here).
upgrading to the newest version of Visual Studio found in "Extensions and Updates"
Using the "Repair" option in the installer.
Uninstalling it completely by uninstalling the "Visual Studio Installer" (Control Panel → Add remove programs), and then re-installing it.
I noticed that on a colleague's computer, which never had VS2017 installed, when I installed VS2017 Community Edition version 15.5, there was no issue.
At this point, I have to admit defeat. The only simple solution is to replace the line in the file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
There is a line near the end of the file:
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'=='' and '$([MSBuild]::IsRunningFromVisualStudio())'=='true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
just replace the $([MSBuild]::IsRunningFromVisualStudio()) with true:
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'=='' and 'true'=='true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
however this only allows the projects to load up - you cannot use it to build the project.
I am going to ask for my machine to be re-imaged so I can just download and install Visual Studio from scratch.
(I hope Microsoft come up with a fix soon.)

MSBuild 15 missing after installation

I have recently upgraded to VS2017 and building with TeamCity. I have a new project that I need to build using TeamCity.
I tried to install MS Build on the CI server from the following link https://www.visualstudio.com/downloads/ it said that it has successfully installed it. Restarted the CI server trying to build the project and still cannot find the new Build tools.
I checked under C:\Program Files (x86)\MSBuild\15.0\ but I dont see the MSBuild.exe
MSBuild 15 missing after installation
If you want use MSBuild without install Visual Studio, you should download and install vs_BuildTools.exe from below link:
https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#
After installation complete, you will find the MSBuild.exe under the path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
For more detail information, you can refer to: How can I install the VS2017 version of msbuild on a build server without installing the IDE?
MSBuild is now local to Visual Studio 2017
and multiple versions can be installed side-by-side (e.g. build tools, previews, community + enterprise, etc.)
So a path to msbuild.exe could look like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

Trying to build nuget package with VS 2017 Team Explorer installed

I installed the VS 2017 TeamExplorer which added a separate VS 2017 install folder. Now when I try to build a nuget package, I get an error saying
The imported project "C:\Program Files (x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin\Roslyn\Microsoft.CSharp.Core.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk. C:\Program Files
(x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin\Microsoft.CSha
rp.CurrentVersion.targets
So it appears now it is trying to use MSBuild from the TeamExplorer install path instead of the Enterprise path.
MSBuild auto-detection: using msbuild version '15.3.409.57025' from
'C:\Program Files (x86)\Microsoft Visual
Studio\2017\TeamExplorer\MSBuild\15.0\bin'.
Is there a way to make the original path (Enterprise) the default for MSBuild?
UPDATE
I will mark this as the answer until a better solution comes along!
This isn't a GOOD answer but I uninstalled the VS 2017 Team Explorer and it now works properly. I still would like to know how we can control this.

How to build a VS2015 solution that has a VS2010 configuration using MSBuild?

I want to build a Visual Studio 2015 C++ solution from the command line using MSBuild. The complication is that I want to build a particular configuration of the solution, which uses the Visual Studio 2010 toolset (necessary because I am linking to a 3rd party library).
I have used MSBuild successfully in the past, but am unsure of which versions of MSBuild and vcvarsall.bat to use in this case. Currently I am running:
"\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
"\Program Files (x86)\MSBuild\14.0\Bin\MSBuild" mysolution2015.sln /p:Configuration="2010_Config" /p:useenv=true
but that gives error:
LINK : fatal error LNK1117: syntax error in option 'manifest:embed'
Any help would be appreciated.
You should be using the vcvarsall.bat from VS2015 ("\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat")
The chosen configuration will select the appropriate toolset (assuming you have both VS2015 and VS2010 installed).
You can then simply use msbuild has it will have been added to the path...