4
Project/
  dub.sdl/
  source/
  examples/
    test/
      source/
        app.d
      dub.sdl

项目/dub.sdl

...
subpackage "./examples/test"
...

项目/examples/test/dub.sdl

name "test"
targetType "executeable"

如果我尝试执行dub run test如果得到以下错误

Failed to parse package description for test in Project/examples/test.
Failed to find a package named 'test'.

如果我尝试执行,也会发生同样的情况dub run :test

4

2 回答 2

2

在命令中,您应该在子包名称前加上根包名称。

dub run rootpackagename:test

看来您需要明确指定run(或build其他命令)。

于 2016-02-10T17:02:10.030 回答
2

截至 2017 年配音版本 1.3.0:<rootpackagename>是可选的。例如,我正在测试jsoniopipe包,如下所示:

# Add dependency which is not found on dub's repo:
git clone https://github.com/schveiguy/iopipe ../iopipe
dub add-local ../iopipe

配音.sdl 文件:

name "jsoniopipe"
description "JSON parser for iopipe"
authors "Steven Schveighoffer"
copyright "Copyright © 2017, Steven Schveighoffer"
license "boost"
targetType "library"
dependency "iopipe" version="*"
subPackage {
   name "formatjson"
   targetType "executable"
   sourcePaths "examples/formatjson"
   dependency "jsoniopipe" version="*"
}

testjson.json 的内容

{
    "name": "myproject",
    "authors": [
        "My Name"
    ],
    "description": "My first project",
    "copyright": "Copyright © 2017, imadev",
    "license": "Boost"
}

运行命令:

dub run :formatjson -- ./testjson.json
于 2017-08-28T08:18:02.450 回答