none
Missing VCToolsRedistDir macro when building from Visual Studio IDE RRS feed

  • Question

  • Hi,

    I was wondering if some special steps are required to get all the macros defined (e.g. VCToolsRedistDir, etc). In my post build script, I need to copy some dll from the directory and $(VCToolsRedistDir) is missing/undefined.

    Do I have to run C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\vsdevcmd\ext\vcvars.bat manually or something?

    Friday, June 21, 2019 7:23 AM

All replies

  • Hi friend,

    Welcome to MSDN forum.

    >>I was wondering if some special steps are required to get all the macros defined

    Sorry but the answer may be negative.

    Cause the macros are defined with the installation of corresponding Workloads and components. They are not all defined with the time we install VS IDE.

    IE: Most of the time we only use C#, or C++ or python workload,  if I install C++ desktop development workload, then vs will define corresponding macros like $(VCToolsInstallDir), but since we don't install C++ Linux development workload, the path of its packages would not exist, so there's no need to define those macros. That's why for now VS doesn't have an option to get all macros defined.

    BTW, if you really want this feature in VS IDE, you could share this suggestion to the VS Product Team in here: https://developercommunity.visualstudio.com/content/idea/post.html?space=8.

    >>And for VCToolsRedistDir macros

    After my check, starting with VS2017 15.x(one version but I'm not sure), this macros is no longer used or defined. The macros which is related to it is $(VCToolsRedistVersion). I will do more check to confirm if it is not supported or it's one issue.

    Here are some suggestions may help:

    1. You can define some macros you want but not defined in VS as OS environments variables

    This way is only suitable for the situation in which the amount of the macros is not large. Also, since you need to define hard-code path like C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Redist\MSVC\14.16.27012 for $(VCToolsRedistDir), sometimes they will cause some error if after an VS update you have newer versions than 14.16.27xxx.

    2. You can create a Directory.Build.props and add content into it like below:

    <Project> <PropertyGroup> <VCToolsRedistDir>$(VCInstallDir)Redist\MSVC\$(VCToolsRedistVersion)</VCToolsRedistDir>

    ... add other custom properties here. </PropertyGroup> </Project>

    Add put the file in C:\Users\xxx\source\repos folder. Then any project(No matter C++ or other projects) in this folder can recognize the property defined it that xx.props file. 

    Also, please let me know what other macros not defined in your side. Maybe what you need is to install a corresponding workload. But I'm not sure with only VCToolRedistDir. 

    Hope it's helpful. Any feedback would be expected!

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, June 21, 2019 11:22 AM
  • The thing to remember is that when you are building using the IDE, there is no attempt to set up a console environment. This means that you have to pass in these values as a parameter to your script.

    For example, I used a simple batch file like:

    @echo off
    if %1 == "" (
    echo No path passed in
    ) else (
    echo Path passed in was %1
    )

    in a post build event. I was getting:

    shown in the build output.

    The command that I used for the post build event was:

    This is enough to tell the script the path to the redist directory.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Friday, June 21, 2019 12:42 PM
  • Hi friend,
    Sorry to bother you, I want to confirm if my reply could reassure you?
    Any new process or feedback is expected and if you were going forward not to stay in here, please ensure if my reply is helpful or not and then mark it as answer. After that, I will help you to close this issue, meanwhile, it will appear in our forum as a solved issue be referenced.
    Have a nice day.

    Sincerely

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 28, 2019 7:08 AM