执行以下测试时,VS 2017 15.5.2在测试项目中发生上述错误。test.vbproj文件中有绑定重定向,但msBuild没有。
<TestMethod()> Public Sub ElementTypeUnitTestAsync()
Dim RoslynPath As String = Path.Combine(RepoPath, SolutionPartialPath)
Dim MS_Workspace As MSBuildWorkspace = MSBuildWorkspace.Create()
AddHandler MS_Workspace.WorkspaceFailed, Sub(sender As Object, e As WorkspaceDiagnosticEventArgs)
Debug.WriteLine(e.Diagnostic.ToString())
End Sub
Dim NewSolution As Solution = MS_Workspace.OpenSolutionAsync(RoslynPath).Result
End Sub
整个信息是
[失败]Msbuild 在处理文件“C:\Repos\roslyn-master\src\Samples\CSharp\APISampleUnitTests\APISampleUnitTestsCS.csproj”时失败,并显示消息:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (1601, 5): 无法从程序集“C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.Build.Tasks.dll”。请验证任务程序集是否已使用与计算机上安装的程序集相同的 Microsoft.Build.Framework 程序集版本生成,并且您的主机应用程序没有缺少 Microsoft.Build.Framework 的绑定重定向。无法将类型为“NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask”的对象强制转换为类型“Microsoft.Build.Framework.ITask”。C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (1601, 5): “GetReferenceNearestTargetFrameworkTask”任务在构造过程中声明或使用不正确,或失败。检查任务名称和程序集名称的拼写。
如果有1个以上的VS实例,该代码将允许选择VS实例
Imports Microsoft.Build.Locator
Public Class VS_Selector_Dialog1
Private m_instance As VisualStudioInstance = Nothing
Private SelectedRow As Integer = -1
Private visualStudioInstances() As VisualStudioInstance = MSBuildLocator.QueryVisualStudioInstances().ToArray()
Public ReadOnly Property MSBuildInstance As VisualStudioInstance
Get
Return m_instance
End Get
End Property
Private Sub Cancel_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Cancel_Button.Click
DialogResult = DialogResult.Cancel
Close()
End Sub
Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
m_instance = visualStudioInstances(DataGridView1.CurrentRow.Index)
End Sub
Private Sub OK_Button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles OK_Button.Click
If m_instance Is Nothing Then
Exit Sub
End If
DialogResult = DialogResult.OK
Close()
End Sub
Private Sub VS_Selector_Dialog1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim BestIndex As Integer = -1
Text = "Multiple installs of MSBuild detected please select one:"
Dim InstanceTable As New DataTable
InstanceTable.Columns.Add("InstanceNumber")
InstanceTable.Columns.Add("Edition")
InstanceTable.Columns.Add("Version")
InstanceTable.Columns.Add("MSBuildPath")
For Index As Integer = 0 To visualStudioInstances.Length - 1
If visualStudioInstances(Index).Name.Contains(" Build ") Then
Continue For
End If
BestIndex = Index
Dim rowToAdd As DataRow = InstanceTable.NewRow()
rowToAdd("InstanceNumber") = Index + 1
rowToAdd("Edition") = visualStudioInstances(Index).Name
rowToAdd("Version") = visualStudioInstances(Index).Version
rowToAdd("MSBuildPath") = visualStudioInstances(Index).MSBuildPath
InstanceTable.Rows.Add(rowToAdd)
Next
DataGridView1.DataSource = InstanceTable
If InstanceTable.Rows.Count = 1 Then
m_instance = visualStudioInstances(BestIndex)
DialogResult = DialogResult.OK
Close()
End If
End Sub
End Class
让用户选择实例,或者您选择“最佳”
If VS_Selector_Dialog1.ShowDialog(Me) <> DialogResult.OK Then
Stop
End If
一旦你有了正确的实例MSBuild将工作
Console.WriteLine($"Using MSBuild at '{VS_Selector_Dialog1.MSBuildInstance.MSBuildPath}' to load projects.")
' NOTE: Be sure to register an instance with the MSBuildLocator
' before calling MSBuildWorkspace.Create()
' otherwise, MSBuildWorkspace won't MEF compose.
MSBuildLocator.RegisterInstance(VS_Selector_Dialog1.MSBuildInstance)
Using Workspace As MSBuildWorkspace = MSBuildWorkspace.Create()
AddHandler Workspace.WorkspaceFailed, AddressOf MSBuildWorkspaceFailed
Dim currentProject As Project = Workspace.OpenProjectAsync(.FileName).Result
Workspace.LoadMetadataForReferencedProjects = True
If currentProject.HasDocuments Then
For Each document As Document In currentProject.Documents
问题内容: 我正在尝试使用将a的布尔值传递给另一个类。由于某些原因,在包含开关的类中,应该将值设置为的语句无法读取开关声明。 ViewController.swift 在第一个If语句(shrimpSwitch.on)中,它将显示Expected Declaration。我是在声明所有开关错误吗?任何帮助,将不胜感激。谢谢 问题答案: 问题是您需要将代码放入方法中。您所需要做的就是将其移动到vie
问题内容: 我收到此错误消息,说我没有使用变量……但是在我的菜鸟眼中,看起来我在: 谁能指出我对语言的缺失?我认为这与vs 和作用域有关,但我不确定。 问题答案: 在您的for循环声明了一个新的变量,其阴影外。将其变成平原以解决问题。 顺便说一下,为了获得相同的精度和更快的速度,您可以尝试以下实现,该实现一次执行两个步骤:
任务“:app:ExternalNativeBuildDebug”执行失败。生成命令失败。执行进程/home/raed/android/sdk/cmake/3.10.2.4988404/bin/ninja时出错,参数为{-c/home/raed/androidstudioprojects/simd/app/.CXX/cmake/debug/armeabi-v7a native-lib}ninja:
问题内容: 我偶然发现了一个奇怪的问题,下面的代码无法编译: 错误(代码是linter推荐的代码)。: 注意,确实使用了该变量。 但是,如果我添加了else块-一切都会按预期编译: 这看起来像是编译器中的错误,还是一个已知问题?任何想法?(我正在使用go 1.11) 编辑:到目前为止的所有被告。按照:https : //golang.org/ref/spec#Short_variable_decl
嘿,我是javascript的初学者,我遇到了这个问题。IF语句似乎将变量识别为它不是的东西。我想这和OR操作员有关? 因此它确实表示
我正处于学习RichFaces和JSF2.x的阵痛中。我在这里使用了一个教程,Eclipse标记了faces-config声明 null