msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

CMake created VS solution foldername conflicts with project/solution name

Open OneOfTheirs opened this issue 3 years ago • 3 comments

Issue Description

If your cmake has set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "{NAME}") line, it creates a project folder in the solution list. However, the folder name must not be the same as any project's or solution's name. Otherwise it will cause Solution file error MSB5004: The solution file has two projects named "xxxx". For example your solution is named "GoodWork.sln", and in your cmake script, you have set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "GoodWork/Test") in any of the CMakeLists.txt, you will see this error.

Expected Behavior

Build correctly.

Actual Behavior

Error Solution file error MSB5004: The solution file has two projects named "xxxx"

Analysis

It won't be a problem if you open the solution with VS and build it there. This project only occur using MSBuild in command line. So that factors out the issue from cmake.

Versions & Configurations

Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework

OneOfTheirs avatar May 08 '21 05:05 OneOfTheirs

Did you try a new MSBuild version? Right now is last release 16.9.0+5e4b48a27.

trivalik avatar May 10 '21 10:05 trivalik

@petergaogithub does this step

It won't be a problem if you open the solution with VS and build it there.

Change the .sln file's contents? I suspect VS is "correcting" the file and then MSBuild can understand it.

If that's the case, we should consider being tolerant in the same way VS is when opening.

rainersigwald avatar May 10 '21 14:05 rainersigwald

For anyone searched to here. No I have never able to fix the issue with the msbuild version I listed. It could have been fixed by cmake too.

OneOfTheirs avatar Aug 04 '22 23:08 OneOfTheirs