In Visual Studio 2013 (or 2015), I have a particular project that in the post-build event, I'm trying to pass $(TargetDir) to a batch file.
The problem is, all the macros are empty, except for the macros beginning in "Solution". Also, all the macros are shown correctly in the "Edit Post-build Event Command line" dialog.
Example
echo ConfigurationName is "$(ConfigurationName)"
Results in
Configuration name is ""
I had the same problem.
According to https://social.msdn.microsoft.com/Forums/vstudio/en-US/179716e8-89eb-40ff-ba13-339e2d25d1c8/outdir-and-targetpath-macros-are-empty?forum=msbuild, you have to delete the PropertyGroup
in the csproj file, and then to add the build event in Visual Studio again.
After you add it again, it will be at the end of the csproj file, and the macros should work.
Try $(Configuration) instead of $(ConfigurationMode), I was having this issue too and this solved it, although I don't know why it happens...
Had the same problem when migrating a project file from old .NET framework format to SDK style.
It seems the structure of the PostBuildEvent changed and is not converted by the "upgrade assistant" tool.
This was the command before:
<PropertyGroup>
<PostBuildEvent>echo ProjectDir: $(ProjectDir)</PostBuildEvent>
</PropertyGroup>
This is the new version:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="echo ProjectDir: $(ProjectDir)" />
</Target>
To do the migration: open the code file (right click on project, "Properties"). Then cut the post build snippet and save the file. Paste the snippet again - now it should have the new format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With