question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object reference error on `dotnet build` if `restore` was not run

See original GitHub issue

During an internal .NET talk we stumbled over following dotnet cli error.

Steps to reproduce

  • Use a project.json with netcoreapp1.1
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      }
    }
  },
  "runtimes": {
    "win8-x64": {},
    "win10-x64": {},
    "osx.10.10-x64": {}
  }
}
  • run dotnet restore

  • run dotnet build -> it works fine

  • edit project.json netcoreapp 1.1 to 1.0

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      }
    }
  },
  "runtimes": {
    "win8-x64": {},
    "win10-x64": {},
    "osx.10.10-x64": {}
  }
}
  • run dotnet build (without restore before!) -> error

Expected behavior

A more detailed error message, that a dotnet restore is required, if netcoreapp version has been changed

Actual behavior

C:\Users\username\temp\clitest>dotnet build
Object reference not set to an instance of an object.

Environment data

dotnet --info output:

C:\Users\username>dotnet --info
.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

Installed SDKs:

  • 1.0.0-preview2-1-003177
  • 1.0.0-preview2-003121
  • 1.0.0-preview2-003131

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TheRealPiotrPcommented, Dec 17, 2016

@BenjaminAbt Thanks for reporting. Since this is a project.json issue and has a known workaround I’m going to close it. Please do try the latest build from this repo’s home page and let us know what you think!

1reaction
nguerreracommented, Dec 16, 2016

Please, please, please stop it with catch (Exception ex) { Console.WriteLine(ex.Message); }!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object reference error on dotnet build if restore was not run ...
During an internal .NET talk we stumbled over following dotnet cli error. Steps to reproduce Use a project.json with netcoreapp1.1 ...
Read more >
dotnet build produces NullReferenceException
This is a known bug in the dotnet CLI. It happens if you add a new framework to project.json but don't run dotnet...
Read more >
Troubleshooting NuGet Package Restore in Visual Studio
This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are...
Read more >
Troubleshoot broken references - Visual Studio
If your application attempts to use a broken reference, an exception error is generated. The main reason for the error is the inability...
Read more >
Fix: "Object Reference Not Set to an Instance of ...
The error message "Object reference not set to an instance of an object" means that perhaps you're referring to an object that doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found