Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2017 MSBuild autodetection takes MSBuild/v14 instead of v15 for WPF project

We are slowly migrating to VS2017 and most of the project do that silently without much interference. Today started migrating a WPF project from VS2015 to VS2017. When I build the solution I get the following warning:

MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.

I googled the problem but I seem to be alone out there. I have no clue what could cause this. The .Net target is 4.5.1 but changing that to 4.6.2 make no difference. Neither does clean or remove bin and obj directories. Who has got a clue?

like image 372
Paul Sinnema Avatar asked Apr 24 '18 08:04

Paul Sinnema


2 Answers

I encountered this problem while building from the command line after migrating from VS2017 to VS2019 for a solution containing class libraries. I found I had VS2017's version of MSBuild in my PATH environment variable - C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin. Removing that path from the environment variable and re-opening my console solved the issue.

like image 144
abarger Avatar answered Sep 20 '22 08:09

abarger


VS2017 MSBuild autodetection takes MSBuild/v14 instead of v15 for WPF project

You can try to update the version of nuget.exe to the 4.0 and above in the .nuget folder.

Visual Studio 2017 comes with NuGet 4.0 and NuGet 4.0 Package Manager Extension is currently not available for Visual Studio 2015 (Visual Studio 2015 comes with NuGet 3.4.4, and NuGet 3.5.0 is available as an explicit download for Visual Studio 2015 as well).

According to your comment, it seems the old nuget.exe not detect the MSBuild version 15.0, so please try to update the nuget.exe to 4.0 and above in the .nuegt folder.

Besides, I found your solution that is still configured by old package restore method "MSBuild-integrated restore", which is the original Package Restore implementation and though it continues to work in many scenarios, it does not cover the full set of scenarios addressed by the other two approaches.

Automatic Package Restore is the NuGet team's recommended approach to Package Restore within Visual Studio. You can convert to use the automatic package restore. Check the following thread for details:

Nuget: Switching from "Enable Package Restore" to "Automatic Package Restore"

Hope this helps.

like image 41
Leo Liu-MSFT Avatar answered Sep 22 '22 08:09

Leo Liu-MSFT