我正在准备一个全新的ASP。NET MVC 5.1解决方案。我添加了一堆NuGet包,并设置它与Zurb基金会等。

作为其中的一部分,我已经添加了一个内部NuGet包的引用,它是一个可移植类库,我认为这在构建服务器上造成了一个问题。

TeamCity在以下情况下构建失败:

系统类型。对象在未引用的程序集中定义。必须向程序集“System”添加引用。= 4.0.0.0运行时版本

我最初在编译Razor网页时为相同或类似的错误添加了修复,该修复在web.config中

<compilation ... >
  <assemblies>
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

然而,这个问题尚未解决。


当前回答

安装https://www.microsoft.com/en-us/download/details.aspx?id=49978 Microsoft . net Framework 4.6.1 Developer Pack并在Web中添加这行代码。配置文件

<compilation debug="true" targetFramework="4.5">
          <assemblies>
            <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
          </assemblies>
        </compilation>

其他回答

向这个System.Runtime.dll程序集添加引用修复了这个问题:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Runtime.dll

尽管那个显式路径下的文件在构建服务器上不存在。

一旦我找到了一些关于PCL和这些facade的文档,我会回复更多的信息。

更新

是的,整个互联网上几乎没有关于表面装配的信息。

谷歌:

(Facades OR Facade) Portable Library site:microsoft.com

唯一适合我的方法是将程序集添加到web.config

<compilation debug="true" targetFramework="4.5">
  <assemblies>     
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />   
  </assemblies>
</compilation>

在我的例子中,.csproj文件以某种方式混淆了。一些“编译”元素缺少一个“子类型”。

<Compile Include="Control.cs" />

修复了再次添加“子类型”的问题:

<Compile Include="Control.cs">
  <SubType>UserControl</SubType>
</Compile>

@PeterMajeed在接受答案中的评论帮助我解决了一个相关的问题。我没有使用可移植库,但在新安装的Windows Server 2012上也有同样的构建错误,我在那里运行TeamCity。

安装Microsoft . net Framework 4.5.1 Developer Pack解决了这个问题(在单独安装了MS Build Tools之后)。

对我有帮助的只有这一行代码:

Assembly.Load("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");