Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complete list of ASP.Net 5 project.json Script Commands? (Visual Studio 2015)

I have looked at the the ASP.Net 5 teams wiki entry for project.json, to identify which Script Commands are available, and currently the following are listed:

{
  "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"
  }
}

These are straightforward, and easy to understand; however in Visual Studio, only prerestore and postrestore events seem to actually fire. Prebuild and postbuild do not.

The default (beta 6) Visual Studio 2015 template adds the following Script Command, which is not on the official list:

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

Additionally, there seem to be other, undocumented commands, I inherited these from a sample project created by a colleague:

  "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"
  }

These seem to work (they execute), but my colleague and I am unable to find documentation to explain:

  1. If they are valid, or deprecated.
  2. If they are specific to Visual Studio (I believe prepublish is only for Visual Studio)
  3. Exactly when they are executed, and how they are recognised by Visual Studio (the names seem obvious, but I prefer to be certain).

To confuse matters further, Visual Studio 2015 intellisense shows other commands which are not in the official list:

enter image description here

Is there a list of valid project.json Script Commands, their usage, etc., especially for Visual Studio 2015?

like image 446
dmcquiggin Avatar asked Aug 24 '15 17:08

dmcquiggin


Video Answer


1 Answers

Update 24/05/2016:

Microsoft is phasing out project.json and returning to 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.

Quote taken from here


An update on the Nuget blog from 30th March 2016 stated that

The latest project.json schema for DNX is supported in the Visual Studio editor and by the NuGet extension

The project.json schema lists the following available script commands :

        "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" }
        }
    },
like image 139
Electric Sheep Avatar answered Oct 05 '22 09:10

Electric Sheep