-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Custom Solution/Project Config Mapping #447
Comments
@jeffkl figured I'd start a new issue to continue the discussion. Not sure if we need this either, but just know it's something I'm seeing with our Uno Platform project configurations, but we're not really focused on trying to build for other platforms like iOS and Android at the moment, so not sure if it's a problem for us. Maybe this is something @jeromelaban from Uno can comment on a bit more about how this works in their system. I do think the properties for msbuild would be the way to go, but probably not a huge priority at the moment. |
I have a similar issue. It would be great if we can define what Configuration to choose for this project in the matrix, based on the SolutionConfiguration. Ie. Conditinally, similar to @michael-hawker <SlnGenSolutionConfiguration Condition='$(Configuration) == Debug'>Foo</... |
We are also looking at using SlnGen for generating our solutions, but will be blocked until we have something to handle these cases. If we can agree on some solution im willing to make a prototype to battle test it, we have some pretty convoluted Configurations. cc @jeffkl for input as well. Also wonder how the Visual Studio team are going to solve this issue for something similar to Traversal projects instead of Solutions; |
I'd be fine with custom mappings of solution platforms to project platforms. The built-in mappings are determined here: https://github.com/microsoft/slngen/blob/main/src/Microsoft.VisualStudio.SlnGen/SlnFile.cs#L663-L803 At the moment only certain platforms are recognized: https://github.com/microsoft/slngen/blob/main/src/Microsoft.VisualStudio.SlnGen/SlnFile.cs#L621-L644 So maybe users need to be able to define what they consider "valid" platforms? Technically SlnGen could just treat all values it finds as valid but it would need checks later on that every single project had a correct mapping. For example:
How would you specify that when building the solution platform The built-in mappings make sense because if a project only defines I think we'd need an MSBuild item to indicate that if the solution platform is a particular value but the project does not support it, which platform to build. <ItemGroup>
<SolutionPlatform Include="Any CPU" Platforms="x64;x86;iPhone" />
<SolutionPlatform Include="x64" Platforms="Any CPU;x86;iPhone" />
<SolutionPlatform Include="x86" Platforms="Any CPU;x64iPhone" />
<SolutionPlatform Include="iPhone" Platforms="Any CPU;x64;x86" />
</ItemGroup> These items redefine the current mappings and indicate that if a solution platform is The items could also just be additive, preserving existing mappings: <ItemGroup>
<SolutionPlatform Include="Any CPU" AdditionalPlatforms="iPhone" />
<SolutionPlatform Include="x64" AdditionalPlatforms="iPhone" />
<SolutionPlatform Include="x86" AdditionalPlatforms="iPhone" />
<SolutionPlatform Include="iPhone" AdditionalPlatforms="Any CPU;x64;x86" />
</ItemGroup> This means for any give solution platform, use the value for AdditionalPlatforms as a fallback mapping for project platform. |
I like the idea of using Items to map between the different platforms. We need the same setup for configurations, and it makes sense to combine them, as Solution Config|Platform can change the Project's Configuration+Platform. <ItemGroup>
<SolutionConfiguration Include="Debug|Any CPU" ConfigurationPlatform="Debug+x64;Debug|x86;Debug|iPhone" />
<SolutionConfiguration Include="Debug|x64" ConfigurationPlatform="Debug|Any CPU;Debug|x86;Debug|iPhone" />
...
</ItemGroup> Then we get the full matrix defined on the choosen Solution Configuration. |
Another thing we also need to remember supporting are
|
Related to #437
Originally posted by @michael-hawker in #446 (comment)
Originally posted by @jeffkl in #446 (comment)
@michael-hawker this is extremely complicated from the command-line. Visual Studio has two concepts: Solution configuration and Project configuration. The hard part is mapping project configurations to solution configurations. When you use the UI, you get a nice grid and can create a solution platform and map it to the appropriate project platform. In some cases you'll want to create a solution configuration like "Custom Thing" but when you build it you want to map that to "x86" for the project.
Since SlnGen is a command-line tool, I haven't found a good way for a user to convey these mappings. At the moment, there are some built-in mappings for C++ projects, when you select a solution platform of Any CPU, it will build x86 or amd64 if the project supports one of those.
What works best is for the projects to convey what they support which is how SlnGen dynamically discovers configurations and platforms. If an SDK-style CSPROJ has:
Then SlnGen will generate a solution with the correct solution platforms and map it to the project platforms. What's missing is any way to convey a mapping. I'm not sure if its worth it at the moment but we could look into something like:
But I'm not sure how many people need this functionality. In the 5 years that I've worked on SlnGen, no one has asked for custom mappings like this...
The text was updated successfully, but these errors were encountered: