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>
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
Post a Comment