C. Moore
C. Moore

Reputation: 93

Asp .Net Core Project.json File

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.

Upvotes: 3

Views: 1590

Answers (1)

Sanket
Sanket

Reputation: 20017

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

Upvotes: 4

Related Questions