.net-corevisual-studio-macrospre-build-eventproject.json

project.json > scripts> precompile - use macro value in script


What I want to do:

Execute some batch file in the pre-build event of a .NET core library.
The batch is located in the project directory, and expects the target path as a parameter.

I have found a way to do this in the context of a project.json file,
But I can not get it to accepts Visual Studio Macros as parameters -
And can not find a single reference as to how this is accomplished.
At the moment, the macros are interpreted as string literals.

What I have:

"scripts": {
                "precompile": 
                [
                    "$(ProjectDir)\\Prebuild.bat $(TargetPath)"
                ]
}

Solution

  • Use %project:Directory% instead of $(ProjectDir)