我终于找到了解决方案,所以我分享它以防有一天有人会遇到同样的问题。问题是,当我出于某种原因卸载 VS 2015 社区时,它没有删除注册表中的密钥,在 VS 输出中我得到了这个异常(但每次我尝试创建项目时它都没有显示,只是有时)
Exception MSBuildToolsPath is not specified for the ToolsVersion "14.0" defined at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0", or the value specified evaluates to the empty string. (InvalidToolsetDefinitionException):
at Microsoft.Build.BuildEngine.InvalidToolsetDefinitionException.Throw(Exception innerException, String resourceName, Object[] args)
at Microsoft.Build.BuildEngine.ToolsetReader.ReadToolset(PropertyDefinition toolsVersion, BuildPropertyGroup globalProperties, BuildPropertyGroup initialProperties, Boolean accumulateProperties)
at Microsoft.Build.BuildEngine.ToolsetReader.ReadEachToolset(ToolsetCollection toolsets, BuildPropertyGroup globalProperties, BuildPropertyGroup initialProperties, Boolean accumulateProperties)
at Microsoft.Build.BuildEngine.ToolsetReader.ReadToolsets(ToolsetCollection toolsets, BuildPropertyGroup globalProperties, BuildPropertyGroup initialProperties, Boolean accumulateProperties)
at Microsoft.Build.BuildEngine.ToolsetReader.ReadAllToolsets(ToolsetCollection toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, BuildPropertyGroup globalProperties, BuildPropertyGroup initialProperties, ToolsetDefinitionLocations locations)
at Microsoft.Build.BuildEngine.Engine.PopulateToolsetStateMap(ToolsetDefinitionLocations locations)
at Microsoft.Build.BuildEngine.Engine..ctor(Int32 numberOfCpus, Boolean isChildNode, Int32 parentNodeId, String localNodeProviderParameters, BuildPropertyGroup globalProperties, ToolsetDefinitionLocations locations)
at Microsoft.Build.BuildEngine.Engine.get_GlobalEngine()
at Microsoft.VisualStudio.Package.Utilities.InitializeMsBuildEngine(Engine existingEngine, IServiceProvider serviceProvider)
at HedgehogDevelopment.SitecoreProject.VSIP.SitecoreProjectPackage.Initialize()
所以我所要做的就是按照这里的解释删除注册表中的密钥。
我按照@Richard Seal
Open registery (regedit)的建议编辑我的问题
导航到 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild(OS 32 位)或 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSBuild(64 位)
在你进一步备份之前注册键(选择 MSBuild 键,然后选择文件 -> 导出)
展开 MSBuild 下的 ToolsVersions,您应该会看到 14.0 出现在 ToolsVersions 下但不在 MSBuild 下,请删除此键
如果您正在运行 VS,您应该重新启动它