It appears that cmake juce generates a group containing the targets (aax, vst…) with the same name as the project containing the shared code. In the .sln file this group is marked as a project.
This causes an issue while using msbuild script command:
pathToBuild/myproject.sln : Solution file error MSB5004: The solution file has two projects named “myproject”.
Naming this group differently like “MyProjectTargets” would fix this issue.
There is however a workaround by opening directly the .vcxproj in msbuild intead of the .sln.