What parameters are available for postcompile script command files?


I am experimenting with creating a .Net Core Project, which is a NETStandard.Library version 1.6.0.

I wanted to experiment with a post build command, but I noticed now that in our project.json file, there is a “postcompile” script that can be created.

Here is the documentation.

I have created a .cmd file, that I am calling from the json file like so:

"scripts": {
"postcompile": ["copyFiles.cmd"]


In my cmd file I can have a simple copy command, which works:

xcopy /y "C:\Playground\test.txt" "C:\Playground\test\"

What I am stuck on, is what variables are now available to me at this point, to give me access to things like the build output directory? I can’t find a reference to this anywhere.

Thanks in advance.


I have been putting in the script compete in the post compile area, using the project directory as a path.

   "scripts": {
    "postcompile": [
      "cmd /c echo %project:Directory%",
      "xcopy /F /Y \"%project:Directory%\\bin\\Debug\\netstandard1.6\\core-minimal-dynamic.dll\" \"%project:Directory%\\..\\dynamic-artifacts\\core-minimal-dynamic.dll\""

For the list of variables available, I think only the following are:

%project:Directory% - The project directory
%project:Name% - The project name
%project:Version% - The project version

(From https://github.com/aspnet/Home/wiki/Project.json-file )


Thank you! I guess I can stick with keeping the script in there for now till I figure out how to pass parameters through to my command file.


If you have a script that picks up arguments with set arg1=%1 (and set arg2=%2) from the command line, you should be able to pass them from Visual Studio.

Dos cmd script

echo off
set arg1=%1
@cmd /c echo %arg1%

.NET Foundation Website | Blog | Projects | Code of Conduct