{ "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中,只有预恢复和后恢复事件似乎实际上已经开始了。预制和后期建筑没有。
默认(beta 6)Visual Studio 2015模板添加了以下脚本命令,该命令不在官方列表中:
"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","gulp default" ],"update": "npm install && npm prune && bower install && bower prune" }
这些似乎工作(他们执行),但我的同事和我无法找到文档来解释:
>如果它们有效或已被弃用。
>如果它们是特定于Visual Studio(我相信预发布仅适用于Visual Studio)
>完全执行它们,以及Visual Studio如何识别它们(名称看起来很明显,但我更希望确定)。
解决方法
微软正在淘汰project.json并返回csproj。
One of the key tenets of .NET as a platform is we want our developers to be able to share code across all of the .NET application models (WinForms,WPF,UWP,ASP.NET,iOS,Android,etc). This presented a series of problems,while project.json was great for building web applications and class libraries it did not allow unification of the other app models.
…
After looking at our choices,it was apparent that it would be easier to move .NET Core projects to .csproj/MSBuild so all .NET projects use the same tooling and build system.
2016年3月30日update on the Nuget blog发布
The latest project.json schema for DNX is supported in the Visual Studio editor and by the NuGet extension
project.json schema列出了以下可用的脚本命令:
"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" } } },