sdk icon indicating copy to clipboard operation
sdk copied to clipboard

dotnet run ./path/to/project throws Object reference not set to an instance of an object.

Open NotMyself opened this issue 10 years ago • 12 comments

Steps to reproduce

Steps fail on both Windows or OSX

clone https://github.com/NotMyself/coreapp cd coreapp & dotnet restore dotnet run ./src/UIMvc dotnet test ./test/UIMvc.Tests

Expected behavior

web project should compile and run test project should compile and run

Actual behavior

web project throws Error: Object not set to an instance of an object. test project runs as expected

Environment data

dotnet --info output:

OSX via iTerm bash .NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

Runtime Environment: OS Name: Mac OS X OS Version: 10.11 OS Platform: Darwin RID: osx.10.11-x64

Windows via PowerShell .NET Command Line Tools (1.0.0-preview1-002702)

Product Information: Version: 1.0.0-preview1-002702 Commit Sha: 6cde21225e

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

selfie-2 GitHub Selfies

NotMyself avatar May 17 '16 21:05 NotMyself

@NotMyself just one item, did you point to a directory with a project.json or to the project.json explictly?

thesmithee avatar May 17 '16 21:05 thesmithee

To a directory with a project.json. You should be able to repro from the git repo posted.

NotMyself avatar May 17 '16 21:05 NotMyself

using dotnet run -p ./src/UIMvc should work, but this error message should really clarify that you need the -p.

itzunagi avatar May 18 '16 14:05 itzunagi

In general, I don't think we should throw exceptions. :smile:

thesmithee avatar May 18 '16 15:05 thesmithee

@degrim that seems inconsistent with the test command shouldn't they both require the -r?

NotMyself avatar May 18 '16 15:05 NotMyself

dotnet test -r should specify the runtime to use, according to dotnet test --help:

-r | --runtime <RUNTIME_IDENTIFIER> Look for test binaries for a for the specified runtime

itzunagi avatar May 18 '16 17:05 itzunagi

bleh, I meant to say -p not -r

NotMyself avatar May 18 '16 18:05 NotMyself

I agree that seems inconsistent.

itzunagi avatar May 18 '16 18:05 itzunagi

Right now, dotnet run is actually the only command that requires the -p when specifying the project.json.

I would argue that instead of simply adding that to dotnet test, we should take a look and see if we can make all the built-in commands for the CLI consistent on how they take a path to the project.json.

We just need to keep in mind that dotnet test/run are special because they also pass arguments down to an underlying app. Run to the app itself and test to the runner.

I particularly prefer the clean way of not having to add the -p, but then, how would we discern a path to project.json passed to run versus one passed to the app?

@blackdwarf can you take a stab at the best design here?

cc @eerhardt

livarcocc avatar May 18 '16 20:05 livarcocc

Ofc. The discern could happen with a special token, e.g. -- or something like that, that would indicate others are to be passed down. Just a though.

thesmithee avatar May 18 '16 20:05 thesmithee

FWIW this was fixed by dotnet/cli#2969 and and dotnet/cli#2980.

vcsjones avatar May 19 '16 20:05 vcsjones

Closing per @vcsjones comment above.

TheRealPiotrP avatar May 26 '16 08:05 TheRealPiotrP