fah*_*ash 12 .net c# code-analysis roslyn
我正在尝试使用MSBuildWorkspace类.我的项目中有所有程序集引用.当我在对象浏览器中打开引用时,我看到了命名空间和我尝试使用的类.但在我的以下使用声明中,
using Microsoft.CodeAnalysis.MSBuild
我得到了一个
The type or namespace name 'MSBuild' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
但有趣的是,Syntax荧光笔识别出类型名称,它的编译器抱怨

这是构建日志
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.VisualBasic.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.CSharp.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.VisualBasic.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3258: The primary reference "Microsoft.CodeAnalysis.CSharp.Workspaces" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "12.0.0.0" than the version "4.0.0.0" in the current target framework.
1>c:\users\fahadash\documents\visual studio 2012\Projects\RoslynEditor\RoslynEditor\MainWindow.xaml.cs(37,36,37,43): error CS0234: The type or namespace name 'MSBuild' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)
1>c:\users\fahadash\documents\visual studio 2012\Projects\RoslynEditor\RoslynEditor\MainWindow.xaml.cs(37,96,37,103): error CS0234: The type or namespace name 'MSBuild' does not exist in the namespace 'Microsoft.CodeAnalysis' (are you missing an assembly reference?)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)
Jas*_*ski 10
所以这:
警告MSB3258:无法解析主要参考"Microsoft.CodeAnalysis.Workspaces",因为它对.NET Framework程序集"Microsoft.Build,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"具有间接依赖性比当前目标框架中的版本"4.0.0.0"更高版本"12.0.0.0".
意味着您正在使用面向.NET 4.0框架的项目构建.您应该使用Visual Studio 2013定位4.5.1.其他配置不受支持.我不建议试图通过消除警告来"强制"这一点 - 这可能只会导致问题.Roslyn使用4.5中添加的API,因此您可能会遇到麻烦,试图解决问题.
| 归档时间: |
|
| 查看次数: |
14693 次 |
| 最近记录: |