Boris Bera
Boris Bera

Reputation: 898

How to structure and run a multi-project dnx project?

I'm trying to get started with DNX but I'm having a hard time figuring out how to structure a multi-project project.

I have done some looking around and I found that it seems like most projects are structured like this:

global.json
src/
  ProjectA/
  ProjectA/project.json
  ProjectB/
  ProjectB/project.json
test/
  ProjectA.Test/
  ProjectA.Test/project.json
  ProjectB.Test/
  ProjectB.Test/project.json

From what I understand global.json points to the different projects and the different project.json files define the specific projects.

I have a similar structure except that I only have a single project named HelloWorld. This project is a console app. I plan on eventually adding more projects and add dependencies between them. For now I just want to be able to build them.

If I go to the src/HelloWorld/ directory and run dnx run it all works. The issue is that I don't want to have to go to that directory. I'd rather be in the root of my project (the directory containing global.json).

How can I run my console app project without having to be in the directory of that specific project? I'd like to be able to do it with something as simple as dnx run.

Upvotes: 0

Views: 127

Answers (1)

David Driscoll
David Driscoll

Reputation: 1419

you can pass the project you want to run, to dnx fairly easily. Unfortunately for your use case it won't make it much easier (although you always make a .cmd/.sh/.ps1 file to do the command for you).

The command would simply be:

dnx -p ./src/HelloWorld run

the -p must be just after dnx, otherwise you won't be passing dnx the argument, as it is going to assume the -p argument will be for the actual command you're trying to run.

Upvotes: 1

Related Questions