3

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. https://learn.microsoft.com/en-us/dotnet/articles/core/tools/project-json

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.

0

1 Answer 1

4

Full list of context variables that you can use to control flow in your scripts is:

Every script block:

%project:Directory%
%project:Name%
%project:Version%

Compile specific:

%compile:TargetFramework%
%compile:FullTargetFramework%
%compile:Configuration%
%compile:OutputFile%
%compile:OutputDir%
%compile:ResponseFile%
%compile:RuntimeOutputDir% (only available if there is runtime output)
%compile:RuntimeIdentifier% (only availabe if there is runtime output)
%comiple:CompilerExitCode% (only available in the postcompile script block)

Publish specific:

%publish:ProjectPath%
%publish:Configuration%
%publish:OutputPath%
%publish:TargetFramework%
%publish:FullTargetFramework%
%publish:Runtime%

References:

https://github.com/aspnet/Home/wiki/Project.json-file#scripts

Post build event depending on configuration name in new ASP.NET 5 project

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, that is a very helpful list. I have noticed that I can get these working if my script is directly within my json file. However if I put my script into a .cmd file, it no longer seems to know what %compile:OutputDir% is anymore, and my script no longer works. Any clue how to get them working in a cmd file?
Sorry.. no idea on that
No I didn't end up getting the cmd file to work unfortunately
@C.Moore you can pass the cmd needed parameters by command line such as myscript.cmd %compile:OutputDir% and in the script access them using $1,$2,...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.