How important is the global.json and src folder?

前端 未结 3 2062
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 10:10

In VS 2015, when you create a new MVC 6.0 application using this approach:

File-->New-->Project-->ASP.NET Web Application-->ASP.NET 5 Preview Templat         


        
相关标签:
3条回答
  • 2021-02-19 10:30

    As you've noted, this seems to be the new way of creating solutions when targeting ASP.NET 5. The global.json file specifies some solution-level settings. In particular, it defines the DNX runtime settings.

    I've seen two approaches to the src / test folder structure. If you look at what the MVC team is doing, they incorporate the src / test folders into the repository root. Many projects on, e.g., Github have a src directory in the root. So as long as you're OK with your global.json and solution files in the root of your project, it seems to align well with existing practices.

    If you look at what the .NET team is doing with the .NET 5 Core Framework, you'll see a similar pattern, albeit without the global.json file. Many of their libraries have src and tests subdirectories.

    I am going to try to pattern my projects after what the MVC team is doing for the time being, until I have a better understanding of .NET 5, DNX, and the rest. It does impose a certain structure on your projects, but then so did VS 2013 and .NET 4.5.

    0 讨论(0)
  • 2021-02-19 10:35

    The src, test, etc. folders allow you to group projects by type. This helps keep the solution maintainable when there are a large number of projects. Here is an example of various project types that have been proposed.

    Per the ASP.NET Core Engineering Guidelines: "By default project-to-project references must be sibling folders. Using a global.json file allows a solution to specify non-standard locations to locate references."

    To sum it up, if have lots of projects, you can group them by type into folders and use global.json to allow projects in one group to reference those in another.

    0 讨论(0)
  • 2021-02-19 10:36

    1) Yes, for me I also had this issue and started with blank solution. Then my projects had issues referencing each others.

    2) For me it did not work without global.json. You also need to make sure the solution file points correctly to everything, like the global.json. The projects did not build and did not find each others for me otherwise.

    3) To get everything working I created a mvc core project first to get the global.json file. Then I renamed the scr folder to applicationname.web. Make sure to alter the solution file accordingly so it does not point wrong. Also you should update the project.json file. This way, all thou I wanted a blank solution like you, I created a default project and then altered it to how I wanted it, that worked for me.

    I will build my current app using Onion Architeture as a guideline. I see no issue doing this with core. This also means that I will build the IoC in a different project (probably named infrastructure.IoC) so that my web project does not contain references to projects containing implementations of interfaces that the web should not know about.

    Also, if you still have problems, I actually got local build and reference problems because I had resharper and I turned that off, then the reference problems between projects went away and I could build successfully.

    0 讨论(0)
提交回复
热议问题