You must add a reference to assembly System.Runtime

I’m attempting to build a pretty simple netstandard2.0 project using GitLab CI. It builds correctly on my local macOS machine against the dotnet core 2.1 sdk. The local build uses the same scripts that GitLab CI is setup to run and yet the CI build always fails with the following:

error CS0012: The type ‘Attribute’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

Here’s the .csproj for the project that isn’t building:

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="AWSSDK.DynamoDBv2" Version="" />
    <PackageReference Include="Bar.Library" Version="1.0.0" />


And the build script:


set -e

cd src/Foo

dotnet build -c Release

And the nuget.config:

<?xml version="1.0" encoding="utf-8"?>
    <add key="enabled" value="true" />
    <add key="automatic" value="true" />

    <add key="Bar Stuff" value="" />
    <add key="Foo Stuff" value="" />

And the .gitlab-di.yml

image: microsoft/dotnet:2.1-sdk

  - build
  - test
  - deploy

  stage: build
    - chmod +x ./scripts/
    - ./scripts/

  stage: test
    - chmod +x ./scripts/
    - ./scripts/

  stage: deploy
    - master
    - chmod +x ./scripts/
    - ./ $MYGET_API_KEY

And the offending code that requires System.Runtime:

using System;

using Amazon.DynamoDBv2.DataModel;

namespace Foo.Data.Profiles.Models
    public class Profile
        public string UserId { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string Bio { get; set; }

        public string Image { get; set; }

        public DateTime CreatedAt { get; set; }

        public DateTime UpdatedAt { get; set; }

I would be eternally grateful for any help on this. I have scoured a lot of boards and tried a lot of possibilities and nothing has worked.

Interesting. I noticed that CI was using dotnet core 2.1.400 and I was using 2.1.302. I upgraded to 2.1.400 locally and now I have this issue.

Modifying the project target from netstandard2.0 to netcoreapp2.1 fixed the build. I’m taking the discussion to the dotnet standard github repo.