13

我有一个使用 DNX 框架的 .NET 5 Web 应用程序,并且我想在构建项目时运行“npm install”、“bower install”等。

现在我可以使用'prepublish'在发布时这样做,但它似乎不适用于'prebuild',虽然我看到它是可能的here

我现在拥有的:

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

4 回答 4

11

从 RC1 开始,您必须“产生输出”才能通过管道构建dnu

图片

图片

于 2015-11-25T10:14:42.203 回答
10

我知道这个问题有点老了,但谷歌把我引向了它。自 2016 年 6 月 19 日起,您应该precompile使用prebuild. 该文件的新文档project.json可在https://docs.microsoft.com/pt-br/dotnet/articles/core/tools/project-json#scripts获得。

project.json 文件的有效脚本选项是:

  • 预编译
  • 后编译
  • 预发布
  • 发表后

微软已经发布了一份声明,表示他们将恢复到旧.csproj格式。您可以在MSDN 博客上了解它。

这一变化的第一波将发生在 Visual Studio “15” RTM 中:在 Visual Studio 中打开任何 .NET Core 项目时,它会自动从 .xproj 转换为 .csproj,将资产从 project.json 文件移动到配置中文件和 .csproj 文件。我们还将提供一个使用 .NET 命令行工具转换应用程序的工具。

于 2016-06-19T19:53:29.950 回答
0

我还没有寻找,beta5但 DNX 有一些关于此处支持的脚本的文档。

基本上是这样的:

{
  "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"
  }
}
于 2015-11-18T14:40:00.057 回答
0

@Stajs's answer is correct but another step may be needed when working with TypeScript, which seems to be the case here.

By default, Visual Studio compiles the TypeScript sources before it pipes the build through dnu. So if there are new tsd type definitions or other references that will only work if tsd install is run first, the build will fail. It's a catch 22.

To prevent Visual Studio from running the TypeScript transpilation, you also have to uncheck the Compile TypeScript on build checkbox on the Properties > Build page.

Note that this only makes sense if you add TypeScript compilation yourself to your gulp or grunt file.

于 2016-01-03T01:33:27.747 回答