我有Visual Studio 2013.我也安装了MSBuild Tools 2013.以下代码给出了异常
var workspace=MSBuildWorkspace.Create();
这是例外
无法加载文件或程序集'Microsoft.Build,Version = 14.0.0.0, Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其中一个 依赖。系统找不到指定的文件。
我做错了什么?
答案 0 :(得分:18)
答案 1 :(得分:3)
您可以针对旧版本的MSBuild编译Roslyn以避免此问题。我用VS 2012完成了这个:
Src/Workspaces/Core/Workspaces.csproj
- <Reference Include="Microsoft.Build, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="Microsoft.Build.Framework, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.Build" />
+ <Reference Include="Microsoft.Build.Framework" />
Src/Workspaces/CSharp/CSharpWorkspace.csproj
- <Reference Include="Microsoft.Build, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="Microsoft.Build.Framework, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="Microsoft.Build.Tasks.$(MSBuildAssemblyNameFragment), Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+ <Reference Include="Microsoft.Build" />
+ <Reference Include="Microsoft.Build.Framework" />
+ <Reference Include="Microsoft.Build.Tasks.v4.0" />
基本上我删除了强名称(请注意,任务程序集的名称虽然不同),所以它从.NET Framework附带的GAC中获取MSBuild,对我来说这是VS 2012的版本。< / p>