Visual Studio $(TargetDir) macro is empty

I encounter this issue in VS2017, it shall apply to older version also.


To repeat the issue:
1. Create a PreBuildEvent, and type below script
echo TargetDir = "$(TargetDir)"


2.  Build the project, you will see:
TargetDir = ""


Solution:
Open the project file with a text editor, then remove the PreBuildEvent section, including the outer <PropertyGroup>. Then re-add the Pre Build Events using Visual Studio.
  <PropertyGroup>
    <PreBuildEvent>
         <!-- Pre build commands go here -->
    </PreBuildEvent>
  </PropertyGroup>

Comments

Popular posts from this blog

Error - vbe6ext.olb could not be loaded