I have an old project in non-SDK-style format generated by Visual Studio. It contains a post-build event in which $(ProjectDir) and $(TargetDir) are used.
I am currently transforming the project into a new SDK-style project (csproj file).
If I just turn that post build event into a Target Exec Command, I get errors. After prefixing the command with echo I could see why: The values $(ProjectDir) and $(TargetDir) were both empty.
I figured out that replacing $(ProjectDir) by $(MSBuildProjectDirectory)\ gives the desired result, but what is the equivalent for $(TargetDir)?
Note that I am not using Visual Studio for the new SDK-style project. I am using Visual Studio Code. It seems that Visual Studio sets values for $(ProjectDir)/$(TargetDir)/others, but Visual Studio Code does not. I build my project using dotnet build.