Skip to content

Port DNX "scripts" concept #4407

Closed
dotnet/cli
#241
@analogrelay

Description

@analogrelay

DNX has a useful scripts construct where scripts can be assigned to run during certain lifecycle events in the dnu build/pack/restore pipelines. We should migrate that concept to dotnet. It is extremely useful for things like incremental compilation of dotnet itself where compiling an individual project can copy the resulting binary into your previous full build so that you don't have to rebuild the whole stack.

It works by adding a scripts section of the following form:

{
    "scripts": {
        "precompile": [ "echo Script 1", "echo Script 2", ... ]
        ...
    }
}

On each event, the scripts in the array are executed in sequence. The scripts can also contain variable replacements in the CMD format (%variable%; this syntax is used even on Unix, since we do the replacement before passing to the shell). Available variables depend on the script, but some examples include %project:ProjectDirectory% which gives the absolute file system path of the project and %compile:TargetFramework% or %compile:Configuration% which give the full framework name and configuration (respectively) currently being compiled.

Events include:

  • precompile: Run after generating the RSP file, and provided the RSP file for potential modification
  • postcompile: Run after the compiler, and provided the path to the output managed binary
  • prepack: Run before packing compiled output into a nuget package
  • postpack: Run after packing output into a nuget package and provided the path to the output package
  • prerestore: Run before dotnet restore/nuget restore
  • postrestore: Run after dotnet restore/nuget restore (often used to tie in other package managers like npm and bower)

/cc @davidfowl

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions