locked
How can I locate and change the $(VCTargetsPath) variable? RRS feed

  • Question

  • I am learning everything about visual studioo now, including the project file structure, msbuild settings, etc.

    And I am now getting into trouble.

    There are macros(variables) in vs project files, such as $(Configuration), $(Platform), $(TargetName), $(UserRootDir).

    So my question are:

    1.  In VS 2019, I can't find an official document describle $(VCTargetsPath). Via google, I found some pages said that this value are defined in regestry, whrer I still can't fine the key. So, where exactly is this variable defined in VS2019? And how to change its value?

    My visual studio works well, I am only wondering how it works.

    2.Is there somewhere defines all these macros/variables as a center, or they are defined respectively?

    Thank you so much for you help!


    • Edited by TruffleWorm Saturday, August 15, 2020 9:05 PM
    Saturday, August 15, 2020 9:05 PM

Answers

  • Hi TruffleWorm,

    We suggest you could install Registry Explorer extension, it could help you find related registries which are used to store macro values.

    In addition, you could also check related targets or props files in VS installation path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise .

    Best Regards,

    Dylan


    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

    • Marked as answer by TruffleWorm Thursday, August 20, 2020 8:02 PM
    Wednesday, August 19, 2020 9:52 AM

All replies


  • 1.  In VS 2019, I can't find an official document describle $(VCTargetsPath). Via google, I found some pages said that this value are defined in regestry, whrer I still can't fine the key. So, where exactly is this variable defined in VS2019? And how to change its value?

    $(VCTargetsPath) is discussed in the official documentation at MSBuild internals for C++ projects.  Why would you want to change its value when you don't know what it is?

    My visual studio works well...

    Leave it alone so it continues to work well. :)


    Sunday, August 16, 2020 10:13 AM
  • Thanks for your help so much:D

    I found the offical document at https://docs.microsoft.com/en-us/cpp/build/reference/common-macros-for-build-commands-and-properties?view=vs-2019. But I still want to modify its value or override it, only because I am curious, of everything about MSBuild . In this journey I have learnt lots about VS.  Before I even not know what is MSBuild.

    So I am still unwared of how to change its value and still waiting for more help.

    Sunday, August 16, 2020 12:22 PM
  • Hi TruffleWorm,

    As RLWA32 shows, these macros are saved into different targets files or props files, for example, $(VSInstallDir) and $(VCIDEInstallDir) are defined into 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Common.props'.

    And they are also defined int the registry tables, for example: $(SDK35ToolsPath) are defined in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0'.

    So if you want to get all macro values, I'm afraid that you need to check multiple configuration files in VS installation and registry tables in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.

    Best Regards,

    Dylan


    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

    Monday, August 17, 2020 9:17 AM
  • Many thanks for your reply!

    In some threads at SO such as MSBuild does not contain a value for the “VCTargetsPath” property

    They mentioned regestry like yours, but only few macros are defined in 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0'.

    Obvioulsy most macros are not defined at regestry, but where to find them and modify them? I can find all the macros in edit dialog box, but they can't be modify.

    Some macros are project-defined and the others are environmental, must be stored somewhere we don't know.

    To be brief, we can start with "How to modify $(TargetName) in vs 2019 if I insist?"

    My questions may be a little weird and insignificant and I apology for that XD


    • Edited by TruffleWorm Monday, August 17, 2020 8:58 PM typo
    Monday, August 17, 2020 8:57 PM
  • Hi TruffleWorm,

    We suggest you could install Registry Explorer extension, it could help you find related registries which are used to store macro values.

    In addition, you could also check related targets or props files in VS installation path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise .

    Best Regards,

    Dylan


    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

    • Marked as answer by TruffleWorm Thursday, August 20, 2020 8:02 PM
    Wednesday, August 19, 2020 9:52 AM
  • Thanks for that clue, and I found that macros are hardly defined in regestry, but many .props files. I am able to change VCTargets now, likely in

    MSBuild\Microsoft\VC\v160\Microsoft.Cpp.ToolsetLocation.props

    but unfontunally, once I change its value, vs can no longer create new project.

    And I successfully created a new macro by modifing that file:

    The full principle and the recusive relation about anythings is not clear yet but this is the best result yet

    Thursday, August 20, 2020 8:10 PM