visual-studio-2015asp.net-core.net-corednx

Can the project.json file in an asp.net 5 (dnx) project be moved?


The default location of project.json is in the root folder of the asp.net project folder. I dislike having configuration files jumbled in with classes and would prefer to move project.json (and other configuration and startup elements) to a Configuration folder.

I moved project.json (in visual studio solution explorer) to a /Configuration folder but it results in the following error:

C:\Program Files (x86)\MSBuild\Microsoft...\DNX\Microsoft.DNX.targets(142,5):
error : The design time host build failed with the following error:
Unable to find project.json in 'Z:\path\to\project\root'

I can't seem to find any configuration detail to indicate where the project.json is located. With all the extensibility and customization possible in the new frameworks did Microsoft hardcode the location of the project.json file?


Solution

  • Short answer is "no". The new project system assumes two things: (1) folder name = project name and (2) project.json is in that folder. project.json is not a configuration file. It is the project metadata just like csproj is for C# projects

    While you still need to have a folder named as the project with a project.json file inside it, you can always include source files from other folders, outside of the project folder. Here's an example of how to do that.