Description
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 modificationpostcompile
: Run after the compiler, and provided the path to the output managed binaryprepack
: Run before packing compiled output into a nuget packagepostpack
: Run after packing output into a nuget package and provided the path to the output packageprerestore
: Run beforedotnet restore
/nuget restore
postrestore
: Run afterdotnet restore
/nuget restore
(often used to tie in other package managers like npm and bower)
/cc @davidfowl