机器安装了VS2010和VS2015后, 又卸载了VS2015,用VS2010打开工程文件,报如下错误:
W:\Common\Common.csproj : error : 无法读取项目文件“Common.csproj”。 Cannot evaluate the property expression "$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))" found at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0@VCTargetsPath". Invalid static method invocation syntax: "[MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\')". Method '[MSBuild]::ValueOrDefault' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(`a`, `b`)).
网上查了一下,原因是卸载VS时,没有把注册表清理干净的原因。
注册表位置:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions 删除所有12或以上的版本即可。
参考: http://stackoverflow.com/questions/26978418/visual-studio-cannot-open-or-make-project