Pre- Post- Build Event Variables in Visual Studio are Empty

1.9k Views Asked by At

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.

1

There are 1 best solutions below

1
On BEST ANSWER

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)\.