<small id='RPmis'></small><noframes id='RPmis'>

    1. <legend id='RPmis'><style id='RPmis'><dir id='RPmis'><q id='RPmis'></q></dir></style></legend>
        <bdo id='RPmis'></bdo><ul id='RPmis'></ul>
      <i id='RPmis'><tr id='RPmis'><dt id='RPmis'><q id='RPmis'><span id='RPmis'><b id='RPmis'><form id='RPmis'><ins id='RPmis'></ins><ul id='RPmis'></ul><sub id='RPmis'></sub></form><legend id='RPmis'></legend><bdo id='RPmis'><pre id='RPmis'><center id='RPmis'></center></pre></bdo></b><th id='RPmis'></th></span></q></dt></tr></i><div id='RPmis'><tfoot id='RPmis'></tfoot><dl id='RPmis'><fieldset id='RPmis'></fieldset></dl></div>
    2. <tfoot id='RPmis'></tfoot>

        VS 2017 通过文件路径引用本地项目(如在 VS 2015 中使用 global.json)

        时间:2023-05-22
        • <bdo id='k5Miz'></bdo><ul id='k5Miz'></ul>

            <i id='k5Miz'><tr id='k5Miz'><dt id='k5Miz'><q id='k5Miz'><span id='k5Miz'><b id='k5Miz'><form id='k5Miz'><ins id='k5Miz'></ins><ul id='k5Miz'></ul><sub id='k5Miz'></sub></form><legend id='k5Miz'></legend><bdo id='k5Miz'><pre id='k5Miz'><center id='k5Miz'></center></pre></bdo></b><th id='k5Miz'></th></span></q></dt></tr></i><div id='k5Miz'><tfoot id='k5Miz'></tfoot><dl id='k5Miz'><fieldset id='k5Miz'></fieldset></dl></div>

              <small id='k5Miz'></small><noframes id='k5Miz'>

            1. <legend id='k5Miz'><style id='k5Miz'><dir id='k5Miz'><q id='k5Miz'></q></dir></style></legend>
                  <tfoot id='k5Miz'></tfoot>

                    <tbody id='k5Miz'></tbody>
                  本文介绍了VS 2017 通过文件路径引用本地项目(如在 VS 2015 中使用 global.json)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  在 VS 2015 中,我们曾经能够像这样在 global.json 中指定本地路径:

                  In VS 2015, we used to be able to specify a local path in global.json like so:

                  {
                      "projects": [ "src", "test", "C:\path\to\other\projects" ]
                  }
                  

                  然后它将该路径中的所有项目添加到当前解决方案中,使我们能够轻松地从现有项目中引用它们.

                  It would then add all the projects from that path to the current solution, allowing us to easily reference them from existing projects.

                  现在 VS 2017 已将其模型更改为使用 csproj,并在此过程中摆脱了 project.json 和 global.json,有人知道这样做的方法吗?

                  Now that VS 2017 has changed its' model to using csproj, and getting rid of project.json and global.json in the process, does anybody know of a way to this?

                  我得到的最好的结果是手动将其他项目一个一个地包含到解决方案中.然后,在所有需要引用它的现有项目中,我将不得不编辑他们的 csproj 以包含它们.与以前在一个位置简单地包含文件路径的方式相比,这确实很麻烦.

                  The best I've gotten is to manually include the other projects, one by one, into the solution. Then, in all the existing projects that need to reference it, I would have to edit their csproj to include them. This is really cumbersome compared to the previous way of simply including a filepath in one location.

                  感谢您对此的任何帮助.

                  Thanks for any help with this.

                  推荐答案

                  好吧,伙计们,现在是 5 月,我们仍然没有来自 Microsoft 的官方解决方案.我使用 Powershell 和新的 .NET core CLI 得到了一些工作.dotnet.exe 中已经内置了用于从项目中添加/删除解决方案的命令,所以这就是我想出的.

                  Alright guys, it's May and we still don't have an official solution from Microsoft. I got something working using Powershell and the new .NET core CLI. There's already commands built into dotnet.exe to add/remove solutions from a project, so here's what I came up with.

                  Includes.json

                  {
                      "Includes": [
                          "C:\projects\SomeProjectA\src",
                          "C:\git\SomeProjectB\src"
                      ]
                  }
                  

                  Add-Includes.ps1

                  echo "Beginning import of projects in Includes.json"
                  
                  $JsonIncludes = (Get-Content -Raw -Path "Includes.json") | ConvertFrom-Json
                  
                  $IncludePaths = $JsonIncludes.Includes;
                  foreach ($IncludePath in $IncludePaths) {
                  
                      $ProjectFiles = Get-ChildItem ($IncludePath + "*") `
                                      -Include *.csproj `
                                      -Recurse `
                                      | % {$_.FullName }
                  
                      foreach ($ProjectFile in $ProjectFiles) {
                          dotnet sln add $ProjectFile
                      }
                  }
                  

                  Remove-Includes.ps1

                  echo "Beginning removal of projects in Includes.json"
                  
                  $JsonIncludes = (Get-Content -Raw -Path "Includes.json") | ConvertFrom-Json
                  
                  $IncludePaths = $JsonIncludes.Includes;
                  foreach ($IncludePath in $IncludePaths) {
                  
                      $ProjectFiles = Get-ChildItem ($IncludePath + "*") `
                                      -Include *.csproj `
                                      -Recurse `
                                      | % {$_.FullName }
                  
                      foreach ($ProjectFile in $ProjectFiles) {
                          dotnet sln remove $ProjectFile
                      }
                  }
                  

                  与使用旧的 Global.json 文件相比,这是几个额外的步骤,但它可以满足我们的需要.为方便起见,请添加一个解决方案文件夹并包含 Includes.json,以便您可以在 Visual Studio 中轻松修改它.

                  It's a couple extra steps compared to using the old Global.json file, but it does what we need. To make it really convenient, add a solution folder and include the Includes.json so you can easily modify it from within Visual Studio.

                  一些注意事项:

                  • 添加/删除脚本几乎完全相同,唯一的区别是 dotnet sln 添加/删除命令.这可能可以清理成一个交互式脚本.
                  • 您还可以进行更改,以便无需单独的添加/删除脚本,只需阅读 Includes.json 并通过解析 .sln 文件将其与解决方案中当前的项目进行比较.

                  只是思考的食物.如果你想克隆/下载,这里是 repo:https://github.com/rushfive/VS2017-Includes

                  Just food for thought. Here's the repo if you want to clone/download: https://github.com/rushfive/VS2017-Includes

                  这篇关于VS 2017 通过文件路径引用本地项目(如在 VS 2015 中使用 global.json)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:防止 Visual Studio 中断未处理的异常 下一篇:Visual Studio - 路径中的非法字符

                  相关文章

                  1. <legend id='VCcep'><style id='VCcep'><dir id='VCcep'><q id='VCcep'></q></dir></style></legend>
                  2. <tfoot id='VCcep'></tfoot>

                  3. <small id='VCcep'></small><noframes id='VCcep'>

                      <i id='VCcep'><tr id='VCcep'><dt id='VCcep'><q id='VCcep'><span id='VCcep'><b id='VCcep'><form id='VCcep'><ins id='VCcep'></ins><ul id='VCcep'></ul><sub id='VCcep'></sub></form><legend id='VCcep'></legend><bdo id='VCcep'><pre id='VCcep'><center id='VCcep'></center></pre></bdo></b><th id='VCcep'></th></span></q></dt></tr></i><div id='VCcep'><tfoot id='VCcep'></tfoot><dl id='VCcep'><fieldset id='VCcep'></fieldset></dl></div>
                      • <bdo id='VCcep'></bdo><ul id='VCcep'></ul>