无法加载Visual Studio 2013中的任何MSBuild项目
我刚开始学习MSBuild,并尝试将下面的简单测试项目加载到Visual Studio 2013(更新5),但我收到错误'The project system has encountered错误' - '给定的密钥不在字典中。'无法加载Visual Studio 2013中的任何MSBuild项目
注意我可以成功地使用MSBuild从命令行构建项目,只是想在VS项目树中看到它作为其他csproj/vcxproj/etc之间解决方案的一部分。项目。
我已经尝试了几种方法,改变msbuildproj文件中的零件等 - 没有成功,总是得到相同的错误。任何想法我做错了什么? MSBuild项目是否应该添加到VS解决方案?
<!-- mytest.msbuildproj -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<Target Name="Build">
<Message Text="Building my target" />
</Target>
</Project>
The project system has encountered an error
VsProjectFault_8c79b7c1-086a-47e9-be8c-46300a431de3.failure.txt:
================== === 01/03/2016 17:10:25 可恢复 System.AggregateException:发生一个或多个错误。 ---> System.Collections.Generic.KeyNotFoundException:给定的键不存在于字典中。 at Microsoft.Collections.Immutable.ImmutableDictionary
2.get_Item(TKey key) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.GetProjectRootProperties(ConfiguredProjectExports configuredProjectExports) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.GenerateOriginalTree(ConfiguredProjectExports configuredProjectExports, CancellationToken cancellationToken) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.<GenerateOriginalTreeAsync>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.VisualStudio.ProjectSystem.Utilities.Designers.ProjectTreeProviderBase.<>c__DisplayClass9.<<Initialize>b__5>d__b.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.Utilities.CommonProjectSystemTools.Rethrow(Exception ex) at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass5.<SubmitErrorReport>b__3() at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2.<Guard>b__0() at GuardMethodClass.GuardMethod(Func
1,Func2 , Func
2) ---内部异常堆栈跟踪结束--- --->(内部异常#0)System.Collections.Generic.KeyNotFoundException:给定关键字没有出现在字典中。 在Microsoft.Collections.Immutable.ImmutableDictionary2.get_Item(TKey key) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.GetProjectRootProperties(ConfiguredProjectExports configuredProjectExports) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.GenerateOriginalTree(ConfiguredProjectExports configuredProjectExports, CancellationToken cancellationToken) at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.<GenerateOriginalTreeAsync>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.VisualStudio.ProjectSystem.Utilities.Designers.ProjectTreeProviderBase.<>c__DisplayClass9.<<Initialize>b__5>d__b.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.VisualStudio.ProjectSystem.Utilities.CommonProjectSystemTools.Rethrow(Exception ex) at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass5.<SubmitErrorReport>b__3() at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2.<Guard>b__0() at GuardMethodClass.GuardMethod(Func
1,Func键2 , Func
2)< ---
===================
不所有的msbuild文件都是相同的。当然你可以从头开始制作一个,然后在命令行上运行它。但这并不意味着Visual Studio会喜欢那个文件。
Visual Studio需要一个具有特定架构的msbuild文件,并且上述文件不适合账单。
不幸的是,如何让MSBuild项目与IDE兼容并不是微不足道的,因此答案被接受。 –
因此,我建议尽可能使用属性表。然后采用VS生成的msbuild文件,并逐行删除它,直到你到达裸露的骨头。 –
项目文件对MSBuild很重要,告诉它该怎么做。然而,它对于IDE来说也很重要,告诉它它应该在解决方案资源管理器窗口中显示的内容。这两个功能并不重叠。这个问题的基本问题是,IDE可以用它做什么都没有用。你应该从IDE创建的一个开始,并且可能倒退。 –
或者就这样,Visual Studio会假定脚本文件包含一系列标签,而该文件未能呈现。所以虽然它是一个有效的MSBuild脚本,但它不是一个有效的VS项目文件。 –
谢谢,这是有道理的。任何想法如何我可以找出哪些标签丢失?我无法从VS IDE创建MSBuild类型项目。 –