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.
Related
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.)
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
It all started with the VS2017 runner type within TC. It was failing without any errors or hints (except the (default targets) -- FAILED. message on the solution level). I narrowed it down to the .sqlproj'ects. These are not building via MSBuild, they do compile perfectly within VS2017 on the build agent.
I was blaming SSDT for it... but I guess I checked everything. This is the problem which bubbles up to the solution level within the TC build:
I noticed that for VS2017 SSDT comes with the VS setup. The "Workload" "Data storage and processing" is installed and so is "SQL Server Data Tools" under "Individual components".
I noticed on https://learn.microsoft.com/EN-US/sql/ssdt/download-sql-server-data-tools-ssdt the sentence "If you are using SSDT with Visual Studio 2017, install the AS and RS components". Did it. Nothing changed. SSDT is also installed separately for previous versions.
This stack is related but it didn't help me.
Any other ideas?
I came a step further. Beside VS the Build Tools are installed as well on the build agent and TeamCity's runner for VS2017 obviously uses MSBuild from the Build Tools.
As you can see above I was reproducing the issue with MSBuild from the Build Tools as well.
If I pick the MSBuild "version" of VS2017 it works like a charm (as it does right within VS).
To make it short:
DOES NOT WORK
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
WORKS
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin
I found a blog post from Lukie Briner, his last paragraph pointed me to the solution (thank you buddy!).
Still don't know why/how this can happen, maybe it is related to the order of the installations of Build Tools, SSDT, Visual Studio etc.?
The reason: SSDT was missing in the Build Tools and its version of MSBuild.
What I have done:
Copy the SSDT folder from
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0
to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0.
WOW! I finally see a REAL error message:
Now I had to copy SQLDB and SQLEditor (I think SQLCommon already existed in the destination folder, if not it should also be copied) from
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft
to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\Microsoft
and BOOM...
And yes, the VS2017 runner from TeamCity is also happy with it.
Seems like the issue with Build Tools and SSDT has been solved now and you don't have to mess with manual copy of targets directories anymore (Visual Studio Build Tools 2017 v15.9.8).
Just open the Visual Studio Installed on the build agent server
Modify Build Tools installation
Select to install the "Data storage and processing tools"
Modify
Build should work now.
We recently installed a new development environment (Windows 10) from scratch with Visual Studio 2017 but we cannot manage to make msbuild compile a Microsoft Office Addin for Word (vsto).
Within the Visual Studio installer we made sure to include the required components for Office Development.
It throws the following error (german translated to english)
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found. Also, tried to find "OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" [...]
However, the project builds fine within Visual Studio.
On the old system, everything works fine, and i cannot remember having to configure anything at all.
You need to install Office build tools when installing Build Tools for Visual Studio 2017
In my case, I managed to get around the issue by copying the folder
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio
from the development environment (the old environment in your case) to
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio
on the build environment (the new environment in your case). I would have thought that one should be able to simply get the relevant targets from the Build Tools for Visual Studio 2017 but that appears not to be the case.
After reinstalling everything it works now.
I guess back then when we set up this machine, the build tools setup was bugged or something.
Now we could install everything we needed for the buildtools using the visual studio installer and it works like a charm.
Okay, so I've worked through this one now. The problem was caused by me using Windows\Microsoft.NET\Framework64\v4...\Msbuild.exe.
It looks as though running msbuild from this location results in it not being able to implicitly locate many of the assemblies and build utilities required to build a VSTO project.
I resolved the problem by switching to using C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe
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...