c# – Asp.net Core 1.0 project.json预发布脚本

嘿这是我的project.json文件的一部分:

  "scripts": {
        "prepublish": [
          "node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js",
          "node node_modules/webpack/bin/webpack.js"
        ],
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
      },

我想在每次发布应用程序时调用预发布脚本,即使它是一个开发环境,我通过visual studio或dotnet run运行它.在这些情况下,预发布似乎不起作用

最佳答案 当您运行VS或使用“dotnet run”时,您只能从源代码构建和运行应用程序,而无需发布.如果您调用dotnet publish,将触发发布脚本.

The dotnet run command provides a convenient option to run your application from the source code with one command. It compiles source code, generates an output program and then runs that program.

现在只有the following types of script are supported

>预编译
>后编译
>预发布
> postpublish

而你想要的更像是“beforerun”/“postrun”.作为一种解决方法,您可以尝试直接从应用程序入口点的代码调用脚本.

点赞