5

When I publish my project with

dotnet publish

it outputs to a folder

bin/Debug/dnxcore50/osx.10.11-x64/publish

(or perhaps the Release equivalent)

Is it possible to determine this folder location for a postpublish script specified in the project.json file?

Brad Robinson
  • 44,114
  • 19
  • 59
  • 88

1 Answers1

12

Thanks to fast response on the dotnet/cli gitter channel, you can. The following variables are available:

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

Source

And here are the ones for pre/postcompile:

%compile:TargetFramework%
%compile:FullTargetFramework%
%compile:Configuration%
%compile:OutputFile%
%compile:OutputDir%
%compile:ResponseFile%
%compile:RuntimeOutputDir%
%compile:RuntimeIdentifier%
%compile:CompilerExitCode%     // postcompile only

Source

Brad Robinson
  • 44,114
  • 19
  • 59
  • 88
  • 2
    These should be documented somewhere... Anywhere! `project.json` is a black box unless one can find the source code and analyse it. – Robula Jul 07 '16 at 14:09
  • @BradRobinson I don't understand exactly how to use these variables. I'm able to display for example OutputPath with `` but not your %compile:OutputPath%. Because I'd like to know how to get the REAL OutputPath, if I display it, I get _.\bin_ instead of _.\bin\Debug\net461\win7-x64_ – Jérôme MEVEL Jul 11 '16 at 07:28
  • 1
    @JérômeMével The above variables are for use in your `project.json` file. I don't believe there is way of resolving `bin\Debug\net461\win7-x64` from MSBuild. However using `%compile:RuntimeOutputDir%` in `project.json` will resolve to `D:\...\\bin\Debug\net461\win7-x64` – Robula Jul 12 '16 at 10:42
  • Ho cool thank you, I didn't think I could finish the job using dotnet cli – Jérôme MEVEL Jul 13 '16 at 02:13
  • @Robula I just found the full project.json schema, it might be useful [link](http://json.schemastore.org/project) – Jérôme MEVEL Jul 13 '16 at 07:31
  • @JérômeMével you absolute legend for finding that schema!! Much help! :) – Robula Jul 13 '16 at 08:45
  • @JérômeMével it does not have the complete list of variables that you can use – Dealdiane Aug 26 '16 at 03:23
  • @Dealdiane anyway project.json will be gone by the end of this year so better not spend to much time and efforts on it – Jérôme MEVEL Aug 26 '16 at 07:09