Object reference error on `dotnet build` if `restore` was not run
See original GitHub issueDuring 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:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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!
Please, please, please stop it with
catch (Exception ex) { Console.WriteLine(ex.Message); }!