2

Have a .NET Core app that I'm trying to use $(ProjectDir) with and when I attempt to pass in that macro, I get an empty value. I tried what was suggested in Issue 26748846, but that didn't seem to solve my issue.

Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95

1 Answers1

4

This happens because in .NET Core projects, the pre- and post build macros are set too early and the $(ProjectDir) property is not yet available. Note that pre- and post build macros are deprecated and should be replaced by proper targets (see https://github.com/dotnet/project-system/issues/1569).

A quick fix would be to replace $(ProjectDir) with $(MSBuildProjectDirectory)\.

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • Splitting the ProjectGroup and adding the targets import in between solved my issue. I wish the .NET Core project would just do that out of the box. Thanks for the GitHub issue link! – Jason N. Gaylord Aug 01 '17 at 12:59