How to change the order of ProjectReference tag in vcproj or vcxproj?

Hyuk Myeong 21 Reputation points
2021-03-18T09:59:55.397+00:00

I'm using MS Visual Studio 2019 to build a c++ project
I have a solution and three projects in it
one is for the executable and others are for the static libraries

Now I want to change the order of linking the libraries for the executable
And finally found that they are linked in the order of its order in project.vcxproj
I changed the order manually with text editor and finally succeeded to get the result

But I don't know how to do it in Visual Studio GUI
If the libraries are described as below in my project.vcxproj
Can I change the order of the libraries with Visual Studio GUI?

bash
...
  <ItemGroup>
    <ProjectReference Include="..\ALibrary\ALibrary.vcxproj">
      <Project>{dbc3f07c-3bf9-4582-99c8-cbd8fe344e5c}</Project>
    </ProjectReference>
    <ProjectReference Include="..\BLibrary\BLibrary.vcxproj">
      <Project>{fbbe1fd4-e968-40d8-aab8-e2a54e9c9268}</Project>
    </ProjectReference>
  </ItemGroup>
...
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. Dylan Zhu-MSFT 6,426 Reputation points
    2021-03-19T02:41:36.937+00:00

    Hi HyukMyeong,

    In visual studio, the items are default sorted by alphabetically in solution explorer, and there are no related options to customize it.

    By the way, from your requirement, you can define different aliases for your same namespace with same class and same method in different libraries.

    Best Regards, Dylan

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our * *documentation* to enable e-mail notifications if you want to receive the related email notification for this thread.**


1 additional answer

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2021-03-18T11:23:01.713+00:00

    Check if this helps: right-click the Solution in Solution Explorer, go to “Project Dependencies…”, then select “BLibrary” from dropdown list and check the “ALibrary” checkbox. Then go to “Build Order” tab to verify the order.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.