3

I've a file custom.props where I define some macro to be used within the project. In the example, I've this:

<VST2_32_COMMAND_ARGS>$(TargetPath) /noload /nosave /noexc /noft</VST2_32_COMMAND_ARGS>

When I load the project, and I look at Properties, Debugging, Command Arguments, I can access to that macro VST2_32_COMMAND_ARGS. But the string is evalutated as /noload /nosave /noexc /noft

Basically, $(TargetPath) is not evaluted. In my case, that path point to a DLL, so it should be somethings like this:

"C:\Program Files (x86)\VstPlugins\Plug\vst2\Win32\bin\MyPlug.dll" /noload /nosave /noexc /noft

But its empty. How could I fix it? Also tried this:

<VST2_32_COMMAND_ARGS>"$(TargetPath)" /noload /nosave /noexc /noft</VST2_32_COMMAND_ARGS>

but the result is:

"" /noload /nosave /noexc /noft
markzzz
  • 47,390
  • 120
  • 299
  • 507
  • I have a similar layout and it works for me. Try to copy-paste contents on common into your props file perhaps to see if it changes anything? – Pavel P Mar 05 '18 at 01:42
  • Except that I don't use it for Debugging / Command Arguments. Try to use that macro in pre/post build step to see if it's evaluated. It might be that in Debugging it works differently. – Pavel P Mar 05 '18 at 01:53

1 Answers1

1

$(TargetPath) not evalutated on loading macro?

To resolve this issue you should import your custom.props file after importing file Microsoft.Cpp.targets:

   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="Custom.props" />

That because the value of Macros for Build Commands and Properties set by the file Microsoft.Cpp.Current.targets:

  <Target Name="SetUserMacroEnvironmentVariables" 
          Condition="'@(BuildMacro)' != '' and '$(DesignTimeBuild)' != 'true'">

    <SetEnv Condition="'%(BuildMacro.EnvironmentVariable)' == 'true'"
        Name   ="@(BuildMacro)"
        Value  ="%(BuildMacro.Value)"
        Prefix ="false">
      <Output TaskParameter="OutputEnvironmentVariable" PropertyName="%(BuildMacro.Identity)"/>
    </SetEnv>

  </Target>

And the file Microsoft.Cpp.Current.targets is imported by the file Microsoft.Cpp.targets:

 <Import Condition="'$(_Redirect)' != 'true'" Project="$(VCTargetsPath)\Microsoft.Cpp.Current.targets" />

So if you call the some macro in your custom file before importing the file Microsoft.Cpp.targets, MSBuild could not get the value of macro.

You can get those .targets files at following path:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets

To verify the custom value of VST2_32_COMMAND_ARGS, I add a simple target to output that value. So you project file should be like:

  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>

  <Import Project="Custom.props" />

  <Target Name="TestByCustom" AfterTargets="Build">
    <Message Text="$(VST2_32_COMMAND_ARGS)"></Message>
  </Target>

After build completed, we could get the value of $(TargetPath):

enter image description here

My custom.props file:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
   <VST2_32_COMMAND_ARGS>"$(TargetPath)" /noload /nosave /noexc /noft</VST2_32_COMMAND_ARGS>
  </PropertyGroup>

</Project>

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I've checked. Its already in this way. This add `IPlugEffects.props` https://github.com/olilarkin/wdl-ol/blob/iplugquake/Examples/IPlugEffect/projects/IPlugEffect-vst2.vcxproj#L81 . Which adds `custom.props`: https://github.com/olilarkin/wdl-ol/blob/iplugquake/Examples/IPlugEffect/projects/IPlugEffect.props#L4 So it should be correct... – markzzz Mar 01 '18 at 07:56
  • 1
    @markzzz, I have checked your project file, it seems you add `IPlugEffects.props` after importing `Microsoft.Cpp.props` rather than `Microsoft.Cpp.targets`, the last few lines of the project file. https://github.com/olilarkin/wdl-ol/blob/18f8273a78f8d77a381f4df7104c814f5b97d335/Examples/IPlugEffect/projects/IPlugEffect-vst2.vcxproj#L447 – Leo Liu Mar 01 '18 at 08:04
  • 1
    I see. I'll try to change it and I'll let you know! Thanks for now. You will get +1 if it will work ;) – markzzz Mar 01 '18 at 08:07
  • 1
    @markzzz, you are always welcome, if it not work for you. Please let me know for free. – Leo Liu Mar 02 '18 at 01:20
  • I'm not really able to config it, due to how that TargetPath is build I think. The correct one shouild be: `C:\Dropbox\Development\C++\wdl-ol\Plugins\IPlug2Test\build-win\vst2\Win32\bin\IPlug2Test.dll` – markzzz Mar 02 '18 at 10:15
  • If I place `$(VCTargetsPath)\Microsoft.Cpp.targets` immediatly after `$(VCTargetsPath)\Microsoft.Cpp.props`, it becomes `C:\Dropbox\Development\C++\wdl-ol\Plugins\IPlug2Test\Debug\IPlug2Test-vst2.dll`, which is wrong and different – markzzz Mar 02 '18 at 10:17
  • So it seems if works only if I place after any `IPlug2Test.props`, but at this point I've the previous problem :( – markzzz Mar 02 '18 at 10:18
  • Anyone? :) Do you get what I'm trying to saying? :) – markzzz Mar 03 '18 at 11:42