如何防止 project.json 浮动版本的开发依赖性扩散?

How to prevent proliferation of development dependencies with project.json floating versions?

我有一个测试实用程序项目(称之为 Utilities.Test),它在其 project.json 文件中将 nuget 包指定为开发依赖项:

{
  "dependencies": {
    "devdep": {
        "version": "*",
        "type": "build"
    }
  },
  "frameworks": {
    "net45": {}
  },
  "supports": {},
  "runtimes": {
    "win": {}
  }
}

我将 Utilities.Test 打包为 nuget 包并尝试在测试应用程序中使用它(称之为 MyProject.Test),将版本指定为 MyProject.Test project.json 文件:

{
  "dependencies": {
    "utilities.test": {
            "version": "*",
            "type": "build"
        }
  },
  "frameworks": {
    "net45": {}
  },
  "runtimes": {
    "win": {}
  }
}

当我这样做时,出现以下编译错误:"Unable to resolve devdep (>= x.x.x) for .NETFramework, Version=4.5"。我找到了两种解决问题的方法:

这两种解决方案都不可接受。我认为将包指定为开发依赖项的全部意义在于防止它被捕获为安装依赖项。在使用浮动版本时,如何防止 devdep 作为依赖项扩散?

我通过将 <developmentDependency>true</developmentDependency> 添加到 Utilities.Test 的 nuspec 文件来解决这个问题。这已经在 devdep 的 .nuspec 文件中指定,所以我不清楚为什么这不足以防止其扩散。现在也完全不清楚 project.json 中的 "type": "build" 标签的目的是什么 - 欢迎对这两个问题有任何见解。