Question Details

No question body available.

Tags

c# .net visual-studio

Answers (1)

Accepted Answer Available
Accepted Answer
September 10, 2025 Score: 1 Rep: 5,953 Quality: High Completeness: 100%

The Configuration and Platform values are primarily for managing compiler settings. For example, the difference for C# between the two standard configurations, "Debug" and "Release", are compiler switches for debug info and optimizations. For "Debug", debug info is on, and optimizations are off.

You can use a solution filter file to work with and build just a subset of the complete solution, e.g. you might create ProductA and ProductB .slnf files.

But revealed in the comments, you want the LibFeatureA library to be built as a different library depending on whether it is being built as a dependency of ProductA or of ProductB. This is simply not supported. Libraries are not expected to change like that.

A project doesn't know (and isn't 'told') when it is being built via a ProjectReference. By design, a project doesn't know what other projects may depend on it.

When a project is built, there is a check performed to determine if the project is already up to date, i.e. that the compiled library is newer than all its source files. An up-to-date project will not be built. If the LibFeatureA library has been built for ProductA, it will be up-to-date and will not be built again when ProductB has a reference.

With the information provided in the question and comments, I can suggest a couple of approaches:

  • Move the source generator and the generated code into both the ProductA and ProductB projects and let each product project generate its own variant. Remove the LibFeatureA library.
  • Create separate libraries for ProductA and ProductB that use the source generator.
  • Create a true common library that supports both ProductA and ProductB.
    • In an OO design, use interfaces and polymorphism.
    • The source generator might be eliminated.