我剛開始學習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很重要,告訴它該怎麼做。然而,它對於IDE來說也很重要,告訴它它應該在解決方案資源管理器窗口中顯示的內容。這兩個功能並不重疊。這個問題的基本問題是,IDE可以用它做什麼都沒有用。你應該從IDE創建的一個開始,並且可能倒退。 –
或者就這樣,Visual Studio會假定腳本文件包含一系列標籤,而該文件未能呈現。所以雖然它是一個有效的MSBuild腳本,但它不是一個有效的VS項目文件。 –
謝謝,這是有道理的。任何想法如何我可以找出哪些標籤丟失?我無法從VS IDE創建MSBuild類型項目。 –