VBC致命错误BC2000:项目已具有对程序集的引用 [英] VBC Fatal error BC2000: Project already has a reference to assembly

查看:153
本文介绍了VBC致命错误BC2000:项目已具有对程序集的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了几天这个问题,没有答案.虽然有对错误代码的引用,但我相信BC2000会用于所有编译器初始化"错误,无论潜在问题是什么.

I've researched this issue for a few days with no answer. There are references to the error code but I believe that BC2000 is used for all "compiler initialization" errors, regardless of the underlying issue.

我有一个VS解决方案,可以在我们的开发环境中使用MSBuild 12.0进行编译.但是,当尝试使用MSBuild 12.0在我们的Win 2008 R2 SP1构建计算机中进行编译时,会出现致命错误.

I have a VS solution that compiles just fine in our dev environment with MSBuild 12.0. However, when trying to compile in our Win 2008 R2 SP1 build machine using MSBuild 12.0, we get a fatal error.

正在为MSBuild执行的命令是:

The command being executed for MSBuild is:

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "path\to\solution.sln" /target:Clean;Build /verbosity:normal /toolsversion:12.0 /nologo /property:WarningLevel="2" /property:Configuration="Release"

收到的错误是:

vbc: Error: Fatal error BC2000 : compiler initialization failed unexpectedly: Project already has a reference to assembly Microsoft.VisualBasic. A second reference to 'path\to\dotnet4\System.dll' cannot be added. (Fatal error BC2000)

这类似于此问题.但是,由于没有使用Mono,因此没有设置它们的用途.

This is similar to this question. However, we don't have the setup their using as we're not using Mono.

该项目只有一个对Microsoft.VisualBasic程序集的引用.而且,正在执行的vbc命令在开发和构建机器中类似,并且它们仅引用一次提到的程序集.

The project in question has only one reference to Microsoft.VisualBasic assembly. Also, the vbc commands being executed are similar in the dev and build machines, and they only refer to the mentioned assembly once.

与开发和构建机器相同:

Same for dev and build machines:

  • .NET Framework版本:4.6.1
  • 正在使用的MSBuild:12.0

不同:

  • Dev计算机具有VS 2010或VS 2013.
  • 构建计算机未安装VS.
  • 构建机器还安装了MS Visual C ++ Build Tools 2015.

以前有人遇到过这个问题吗?关于如何解决它的任何想法?谢谢.

Has anybody come across this issue before? Any ideas on how to fix it? Thanks.

推荐答案

在开发机中运行构建时,我检查了vbc命令(巨大,因此我不会发表),它正在链接到Microsoft.VisualBasic. dll在以下文件夹中:

When running the build in the dev machine, I checked the vbc command (huge, so I won't post) and it was linking to Microsoft.VisualBasic.dll in the following folder:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

我注意到该文件夹​​在构建计算机中不可用,因为它没有.Net Framework 4 SDK.因此,我安装了适用于Windows 7和.NET Framework 4的Microsoft Windows SDK"(是的,即使构建机器为Win 2008 R2)也可以使用.

I noticed that this folder was not available in the build machine, as it did not have the .Net Framework 4 SDK. So I installed the "Microsoft Windows SDK for Windows 7 and .NET Framework 4" (yes, even though the build machine as Win 2008 R2) and it worked.

现在,要安装该SDK,我必须先卸载.Net Framework,因为它是较新的版本,然后安装.Net Framework 4,然后安装上述SDK,然后再次更新至.Net Framework 4.6.1.

Now, to install that SDK, I had to first uninstall the .Net Framework because it was a newer version, then install .Net Framework 4 and then the mentioned SDK, and then update again to .Net Framework 4.6.1.

因此,总而言之:

  1. 在构建计算机中执行MSBuild并将输出重定向到日志文件
  2. 打开日志文件并检查失败的vbc命令
  3. 在开发机中执行MSBuild,并将输出重定向到日志文件
  4. 打开日志文件并找到步骤2中标识的命令
  5. 检查所涉及的程序集(从错误中)的位置
  6. 如果它是与我在一开始所说的目录相似的目录,则可能您需要为所述版本的.Net Framework安装SDK.就我而言,该目录具有该v4.0,因此该目录适用于.Net Fw 4.0.

希望这可以帮助其他人.

Hopefully this helps someone else out there.

这篇关于VBC致命错误BC2000:项目已具有对程序集的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆