Is .sln file required by Visual Studio for ASP.NET 5 project? Can it just use Global.json?

前端 未结 2 1333
旧巷少年郎
旧巷少年郎 2021-01-17 21:42

In a ASP.NET 5 project Visual Studio creates a SLN file. There is also a global.json file which my understanding was the core solution file.

<
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 22:23

    First of all I find your question very interesting, but I find incorrect to compare .sln file with global.json or old .xproj file with project.json because there have not the same goals. Moreover I want to mention some other important files like package.json, bower.json (which are visible if one click on "Show All" button of the solution) and an important launchSettings.json file, which one find in Properties (see the documentation for more details).

    It's clear that the format of .sln file and .xproj file have to be changed and simplified in the future. On the other side, there are some goals of old files, which one have to take in considerations. I want just mention someone.

    First of all, it's important not only to build the code, but to debug or to start the target with some parameters. If I develop Web Api component, for example, then I can need to build it and then to test some methods (actions) by opening the URLs like http://localhost:4745/api/product. Configuring the App URL in GUI of Visual Studio will change the file Properties\launchSettings.json and to include something like

    "iisSettings": {
      "windowsAuthentication": false,
      "anonymousAuthentication": true,
      "iisExpress": {
        "applicationUrl": "http://localhost:4745/api/product",
        "sslPort": 0
      }
    }
    

    inside.

    The next typical problem. I want to test, whether the new component (the new Web Api) work correctly with my old Visual Studio Project. I can, for example, create new Web Site or another Project, which call the Web Api from JavaScript (HTML page which use jQuery.ajax fox example).

    The old .sln file allows us to inform Visual Studio to start Web Api project every time when I start the Test Project (or Test Web Site). Such dependency can't be configured by new .json files.

    One more example could be important to mention. It's clear that one have a lot of existing components and class libraries. It's don't required to rewrite all there at once. To be able to use the old components and to switch to "new world" step by step one need to use old .sln file and some old .xproj in one solution together with new ASP.NET project. I have to mention the issue, which describes some problems with integration of Class Library in the ASP.NET 5 solution. One see that not all problems are solved now, but it should work in RC2 or in RTM.

    My answer is clear not full. I'm sure that the format of .sln file and .xproj file will be changed soon, but I suppose that we will get some new .json files, because the existing files (project.json for example) don't contains all information, which one would like to have in the solution if one would think about testing and debugging of multiple projects and not only about building the target binaries.

提交回复
热议问题