17

我查看了project.json的ASP.Net 5团队 wiki 条目,以确定哪些脚本命令可用,目前列出了以下内容:

{
  "scripts": {
    "prebuild": "echo before building",
    "postbuild": "echo after building",
    "prepack": "echo before packing",
    "postpack": "echo after packing",
    "prerestore": "echo before restoring packages",
    "postrestore": "echo after restoring packages"
  }
}

这些简单明了,易于理解;但是在 Visual Studio 中,似乎只有 prerestore 和 postrestore 事件实际上会触发。Prebuild 和 postbuild 没有。

默认(beta 6) Visual Studio 2015模板添加了以下Script Command,官方列表中没有:

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }

此外,似乎还有其他未记录的命令,我从同事创建的示例项目中继承了这些命令:

  "scripts": {
    "first-run": "npm install -g gulp bower && npm run update",
    "prepare": [ "npm install && npm prune && bower install && bower prune && gulp default" ],
    "prepublish": [ "npm install", "bower install", "gulp default" ],
    "update": "npm install && npm prune && bower install && bower prune"
  }

这些似乎有效(他们执行),但我的同事和我无法找到解释的文档:

  1. 如果它们有效或已弃用。
  2. 如果它们特定于 Visual Studio(我相信预发布仅适用于 Visual Studio)
  3. 确切的执行时间,以及 Visual Studio 如何识别它们(名称似乎很明显,但我更愿意确定)。

为了进一步混淆问题,Visual Studio 2015 intellisense 显示了不在官方列表中的其他命令:

在此处输入图像描述

是否有有效的project.json 脚本命令列表、它们的用法等,尤其是对于 Visual Studio 2015?

4

1 回答 1

5

2016 年 5 月 24 日更新:

微软正在逐步淘汰 project.json 并返回 csproj。

.NET 作为平台的关键原则之一是我们希望我们的开发人员能够在所有 .NET 应用程序模型(WinForms、WPF、UWP、ASP.NET、iOS、Android 等)之间共享代码。这带来了一系列问题,而 project.json 非常适合构建 Web 应用程序和类库,它不允许统一其他应用程序模型。

...

在查看了我们的选择之后,很明显将 .NET Core 项目迁移到 .csproj/MSBuild 会更容易,因此所有 .NET 项目都使用相同的工具和构建系统。

引用自这里


2016 年 3 月 30 日在 Nuget 博客上的更新指出

Visual Studio 编辑器和 NuGet 扩展支持 DNX 的最新 project.json 架构

project.json 架构列出了以下可用的脚本命令:

        "scripts": {
        "type": "object",
        "description": "Scripts to execute during the various stages.",
        "properties": {
            "precompile": { "$ref": "#/definitions/script" },
            "postcompile": { "$ref": "#/definitions/script" },
            "prepack": { "$ref": "#/definitions/script" },
            "postpack": { "$ref": "#/definitions/script" },
            "prepublish": { "$ref": "#/definitions/script" },
            "postpublish": { "$ref": "#/definitions/script" },
            "prerestore": { "$ref": "#/definitions/script" },
            "postrestore": { "$ref": "#/definitions/script" },
            "prepare": { "$ref": "#/definitions/script" }
        }
    },
于 2016-04-11T11:37:57.463 回答