How bazel-contrib/rules_dotnet works
Main Components
• Build System Integration Component: At the heart of the project is Bazel. Represent the Bazel engine along with its configuration files (e.g., .bazelrc, BUILD.bazel, MODULE.bazel). This shows the overall orchestration.
• Dependency Resolution & Packaging: Highlight how Paket (and the related tools in the “paket” directories) integrates with Bazel, as well as the role of NuGet-related build rules (in dotnet/private/rules/nuget). This component manages external dependencies and package versions.
• Test and Verification Modules: Illustrate the extensive testing setup (inside dotnet/private/tests and e2e). These tests cover a range of scenarios such as dependency resolution, source generation, and publishing scenarios. Clearly show how these tests validate the build rules.
• Development & CI/CD Configuration: Show support files and directories, including:
• CI configuration (.bazelci, .github/workflows) to integrate with BuildKite and GitHub actions.
• Development environment configuration (.devcontainer for containerized dev setups).
• Documentation and Examples: Include the docs and examples directories. These illustrate the end-user integration with the rules and provide guidance for adopting the system.
Relationships and Data Flow
• Testing components as a separate validation layer that feeds back into ensuring the integrity of the csharp, fsharp, and packaging rules.
• Link the CI/CD components with the build system to represent automated testing and release pipelines.
Architectural Patterns and Key Design Principles
• Modularity: The project splits responsibilities into discrete packages (e.g., rules for C#, rules for F#, dependency resolution) which can be independently maintained and updated.
• Extensibility: The presence of extension points (for NuGet, for toolkit resolution, and for source generation) suggests that the design anticipates future feature additions and support for more platform-specific optimizations.
• Layered Abstraction: There is a clear separation between the build orchestration (Bazel), rule definitions (dotnet/private/rules), SDK/toolchain integration (dotnet/private/sdk), and the testing/validation infrastructure.