11

This is about an obsolete pre-release version of .net core.

I have created a basic project in pre-release ASP.Net 5 (later on was renamed to asp.net core) using a beta/preview of visual studio 2015, I have published the project to a file system and am trying to run it from there using the command

    dnx . web

the error that results is 'unable to resolve project'. I have checked that dnvm is using the default framework. My published directory has web, web.cmd, wwwroot, and approot folders. Is there anything else I should be checking?

I am using: asp.net core 1.0.0-beta4 clr

Warren P
  • 65,725
  • 40
  • 181
  • 316
Stradosphere
  • 1,285
  • 3
  • 14
  • 40
  • are you running the command from the folder having `project.json` file? – Kiran Jun 30 '15 at 16:53
  • Actually, no i wasn't I was assuming it needed to be run from the root of the published path because that is where the web command ends up. The folder that contains project.json is under the src folder after publish, does that sound right? – Stradosphere Jun 30 '15 at 18:47
  • Well it appears to fire up the web server, but nothing is served. Right now I am just trying to serve a static index.html file, which folder is it actually using as its root for the web server? is it the approot or wwwroot folder? – Stradosphere Jun 30 '15 at 19:05
  • Ok nevermind, I figured it out. Everything is being served from wwwroot, but you need to fire up the DNX Web command from the approot folder, in whichever subfolder has your project.json file. Seems a bit awkward but is now working, thanks for your help Kiran. – Stradosphere Jun 30 '15 at 19:28
  • related: http://stackoverflow.com/questions/33675952/dnx-web-on-ubuntu-14-04-throws-system-runtime-interopservices-marshal-exceptio – Warren P Nov 12 '15 at 16:39

2 Answers2

27

For ASP.NET Core projects, instead of running from the solution directory, you should go down a few folders further.

So for me, for example, I find that if I am at the solution directory I get the same error as you.

/home/myname/AspNetWebApplication <-- solution root folder

versus

/home/myname/AspNetWebApplication/src/AspNetWebApplication <-- project root folder

For me however there are still more things wrong on my setup, as I get "Error unable to load application or execute command".

In early betas and RC1, dnx web or dnx kestrel is the command to run, and that the dot you're typing in between is not needed in my case. In 1.0 rtm it's dotnet run to run from the project source directory and dotnet <yourassemblynamehere>.dll to run your binary, replace with the name of YOUR main binary assembly.

It is good to check that the tool (dnx or dotnet) is in the path, and that my environment is installed as per the ASP.NET Core installation instructions.

Warren P
  • 65,725
  • 40
  • 181
  • 316
  • Thanks. This works for me aswell, but are there a way to start from solution root? – Moddaman Dec 11 '15 at 09:23
  • Make a batch file (windows) or shell script (linux)? cd projectdir then dnx web – Warren P Dec 12 '15 at 01:21
  • Thanks your instructions helped me to get it working. About the dnx command: if you type in dnx web, you are actually starting dnx with as sub command web. The sub commands available are defined in the project.json file, which is in the same folder as you start the application. Web is default I guess (template), but you can change it and make it whaterver command you want. – Maarten Kieft Dec 13 '15 at 18:49
  • That makes sense. So you can write your own ones to run unit tests, or perhaps to do some deploy-time tasks or diagnostics. – Warren P Dec 13 '15 at 18:52
-1

various dnx commands appear to only operate in the "expected" folder within your application. For example with SQL scaffolding, it has to be directly in the models folder, otherwise there are issues.

enter image description here

David Crook
  • 2,722
  • 3
  • 23
  • 49