ubisoft / Sharpmake

Sharpmake is an open-source C#-based solution for generating project definition files, such as Visual Studio projects and solutions, GNU makefiles, Xcode projects, etc.
Apache License 2.0
922 stars 168 forks source link

Custom fragments causing issues when Target `Name` string is overriden #375

Closed CybernetHacker14 closed 1 month ago

CybernetHacker14 commented 1 month ago

Hi,

So I have defined a custom fragment Mode, which contains Mode.Engine and Mode.Tool. I have also defined a custom Target, derived from ITarget. The Sharpmake ecosystem for my project is setup in such a way that using command line, I can generate the solution with the specified mode I want, which will carry on the information to associated projects and so on.

However, when the solution is generated in Visual Studio, I get the configuration options as Engine_vs2022_Debug_Win64 , Engine_vs2022_Release_Win64 , Engine_vs2022_Retail_Win64 , instead of the original Debug, Release, Retail`.

Overriding the custom target's Name property to Optimization.GetString() throws an error Project contains distinct configurations with the same name, please add something to distinguish them

How can I fix this error and also achieve getting the original optimization strings value in the configuration options?

CybernetHacker14 commented 1 month ago

I think so I found the issue - instead of changing the ITarget's Name property - I instead need to change the Solution.Configuration.Name property in ConfigureAll() function call in order to display the right string in Visual Studio.

bchampoux commented 1 month ago

@CybernetHacker14 customizing the Name of project and solution classes is the typical way to address these clashes so well done 🙂