Skip to content

Add cross-platform .NET build support and NuGet cache configuration#27

Open
Mosch0512 wants to merge 5 commits intomainfrom
dotnet-build
Open

Add cross-platform .NET build support and NuGet cache configuration#27
Mosch0512 wants to merge 5 commits intomainfrom
dotnet-build

Conversation

@Mosch0512
Copy link
Owner

Move .NET ClientLibrary and ConstantsReplacer builds out of the MSVC-only block so they work with any compiler (including MinGW cross-builds from WSL).

Key changes:

  • Detect dotnet.exe first (for WSL interop), fallback to dotnet
  • Convert Linux paths to Windows UNC paths (wslpath -w) when calling Windows dotnet.exe from WSL, since MSBuild treats '/' as a switch prefix
  • Guard wslpath calls with CMAKE_HOST_SYSTEM_NAME to avoid errors on native Windows
  • Add MU_NUGET_CACHE_DIR cache variable (defaults to /.nuget)
  • Fix MinGW linker order: opengl32/dwmapi must follow imgui static lib
  • Add _deps/ to .gitignore for locally-built dependencies

@gemini-code-assist
Copy link

Summary of Changes

Hello @Mosch0512, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the build system's flexibility by enabling cross-platform compilation for .NET components, particularly for WSL environments. It addresses specific challenges related to path handling and compiler detection when integrating Windows-based .NET tools within a Linux build context, and provides better control over NuGet caching. Additionally, it includes a fix for MinGW linker order and updates the '.gitignore' for better dependency management.

Highlights

  • Cross-platform .NET Build Support: The .NET ClientLibrary and ConstantsReplacer builds have been moved out of the MSVC-specific block, enabling them to work with any compiler, including MinGW cross-builds from WSL.
  • WSL Interoperability for .NET: Enhanced detection for 'dotnet.exe' (prioritizing WSL interop) and implemented conversion of Linux paths to Windows UNC paths using 'wslpath -w' when calling Windows 'dotnet.exe' from WSL, to prevent MSBuild from misinterpreting '/' as a switch prefix. These 'wslpath' calls are guarded by 'CMAKE_HOST_SYSTEM_NAME' to avoid errors on native Windows.
  • NuGet Cache Configuration: A new cache variable 'MU_NUGET_CACHE_DIR' has been introduced, defaulting to '/.nuget', allowing users to configure the NuGet package cache directory.
  • MinGW Linker Order Fix: Corrected the MinGW linker order by ensuring 'opengl32' and 'dwmapi' follow the 'imgui' static library, addressing order-sensitive linking issues.
  • Git Ignore Update: Added '_deps/' to the '.gitignore' file to exclude locally-built external dependencies from version control.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added '_deps/' to ignore locally-built external dependencies.
  • src/CMakeLists.txt
    • Relocated .NET ClientLibrary and ConstantsReplacer build logic from the 'if (MSVC)' block to a platform-agnostic section.
    • Implemented 'find_program' to locate 'dotnet.exe' (for WSL interop) or 'dotnet'.
    • Introduced logic to convert Linux paths to Windows UNC paths ('wslpath -w') for variables like 'DOTNET_PROJ', 'DOTNET_TEMP_OUTPUT', 'DOTNET_NUGET_DIR', and 'DOTNET_TEMP_DIR' when 'dotnet.exe' is used from a Linux host.
    • Defined 'MU_NUGET_CACHE_DIR' as a cache variable for specifying the NuGet package cache location.
    • Updated 'dotnet publish' and 'dotnet build' commands to use the dynamically found 'DOTNET_EXECUTABLE' and the platform-appropriate native paths.
    • Added a warning message if the .NET SDK is not found, indicating that the Client Library will not be built.
    • Modified 'target_link_libraries' for the 'Main' target to explicitly link 'opengl32' and 'dwmapi' after 'imgui' when 'ENABLE_EDITOR' is true, specifically for MinGW's order-sensitive linker.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the build process by adding cross-platform support for the .NET components, which is a great enhancement. The changes correctly handle path conversions for WSL environments and introduce a configurable NuGet cache directory. The fix for the MinGW linker order is also a valuable correction. I've included a couple of suggestions to refactor some duplicated logic in the CMake script, which will improve its maintainability. Overall, this is a well-executed and important update.

Move .NET ClientLibrary and ConstantsReplacer builds out of the MSVC-only
block so they work with any compiler (including MinGW cross-builds from WSL).

Key changes:
- Detect dotnet.exe first (for WSL interop), fallback to dotnet
- Convert Linux paths to Windows UNC paths (wslpath -w) when calling
  Windows dotnet.exe from WSL, since MSBuild treats '/' as a switch prefix
- Guard wslpath calls with CMAKE_HOST_SYSTEM_NAME to avoid errors on
  native Windows
- Add MU_NUGET_CACHE_DIR cache variable (defaults to <project>/.nuget)
- Fix MinGW linker order: opengl32/dwmapi must follow imgui static lib
- Add _deps/ to .gitignore for locally-built dependencies
- Add docs/build-guide.md: comprehensive guide covering all build
  scenarios (WSL+MinGW, CLion via Z: drive, CLion native Windows, VS presets)
  with step-by-step setup instructions and directory layouts
- Update README.md: fix CMake minimum version (3.25), fix CLion working
  directory to use build output instead of src/bin
@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the build system by adding cross-platform support for .NET components, which is a great enhancement for developers on different systems, especially WSL. The changes are well-structured, and the addition of a detailed build guide is very helpful. I've identified a minor typo in the new documentation and a couple of opportunities in the CMake scripts to improve maintainability by reducing code duplication. Overall, this is a solid contribution.

- Add mu_native_path() macro to deduplicate WSL path conversion logic
  (used by both ClientLibrary and ConstantsReplacer targets)
- Skip .NET build when Linux dotnet targets Windows (cross-OS Native AOT
  is not supported) — fixes CI workflow failure on GitHub Actions
- Only link opengl32/dwmapi after imgui for non-MSVC compilers (MinGW
  needs correct link order, MSVC doesn't)
- Fix "Visual Studio 2026" typo in build guide
@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the build system by adding cross-platform support for .NET components, particularly for developers using WSL and MinGW. The changes are well-structured, moving the .NET build logic out of the MSVC-specific block and introducing clever mechanisms like wslpath integration to handle path differences between Linux and Windows. The addition of a configurable NuGet cache directory is also a welcome improvement for build consistency. The new docs/build-guide.md is an excellent and thorough piece of documentation that will surely help developers navigate the various build scenarios.

My review includes a couple of suggestions: one to fix a path in the new build guide, and another to make the wslpath handling in the CMake script more robust against potential failures. Overall, this is a high-quality contribution that enhances the project's developer experience.

… path

- Add RESULT_VARIABLE check to mu_native_path macro so wslpath failures
  produce a clear FATAL_ERROR instead of silently passing Linux paths
- Fix imgui submodule path in build guide (src/ThirdParty/imgui, not
  src/dependencies/imgui)
@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant improvements to the build system by adding cross-platform .NET build support, particularly for MinGW cross-builds from WSL. The changes are well-thought-out, including the logic to detect the correct dotnet executable and handle path translations. The addition of the build-guide.md provides excellent documentation for the new, more complex build scenarios. I have one suggestion to further improve the maintainability of the new CMake logic. Overall, this is a high-quality contribution that greatly enhances the project's build flexibility.

@Mosch0512
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the project's build system by introducing robust cross-platform support for .NET ClientLibrary and ConstantsReplacer builds, moving them out of the MSVC-only block. Key improvements include intelligent detection of dotnet.exe (with WSL interop considerations), proper path translation for Windows UNC paths when building from WSL, and configurable NuGet cache location to mitigate issues with special characters in user profiles. The addition of docs/build-guide.md is an excellent contribution, providing comprehensive instructions and insights into the various build scenarios and their tradeoffs. The fix for MinGW linker order sensitivity for ImGui dependencies also improves cross-platform compatibility. Overall, these changes greatly improve the flexibility and maintainability of the build process.

@Mosch0512
Copy link
Owner Author

/gemini summary

@gemini-code-assist
Copy link

Summary of Changes

This pull request significantly enhances the project's build system by introducing robust cross-platform support for .NET components, particularly improving compatibility and performance within Windows Subsystem for Linux (WSL) environments. It streamlines the build process by intelligently handling path translations and NuGet caching, ensuring a more consistent and reliable development experience across different operating systems and IDEs. The changes also include crucial linker fixes for MinGW and comprehensive documentation to guide developers through various build configurations.

Highlights

  • Cross-Platform .NET Build Support: The build logic for the .NET ClientLibrary and ConstantsReplacer has been refactored to be platform-agnostic, moving it out of the MSVC-specific block. This enables successful builds with various compilers, including MinGW cross-builds from WSL.
  • WSL Interoperability for .NET: The build system now intelligently detects dotnet.exe (prioritizing the Windows binary for WSL interop) and converts Linux paths to Windows UNC paths using wslpath -w when invoking Windows dotnet.exe from WSL. This prevents MSBuild from misinterpreting Linux path separators as command-line switches. These wslpath calls are conditionally executed based on CMAKE_HOST_SYSTEM_NAME to avoid errors on native Windows.
  • Configurable NuGet Cache: A new CMake cache variable, MU_NUGET_CACHE_DIR, has been introduced, allowing users to specify the NuGet package cache directory. It defaults to <project>/.nuget, addressing potential issues with special characters in user profile paths and improving build reliability.
  • MinGW Linker Order Fix: The MinGW linker order has been corrected for the Main target. opengl32 and dwmapi are now explicitly linked after the imgui static library when ENABLE_EDITOR is active, resolving order-sensitive linking issues specific to MinGW.
  • Comprehensive Build Guide Documentation: A new docs/build-guide.md file has been added, providing detailed explanations of the build system's behavior across supported environments (WSL, CLion, Visual Studio), setup instructions, performance considerations, and directory layouts for various scenarios.
  • Updated Build Requirements and Git Ignore: The minimum CMake requirement has been updated to 3.25 in README.md. Additionally, _deps/ has been added to .gitignore to exclude locally-built external dependencies from version control.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added _deps/ to exclude locally-built external dependencies from version control.
  • README.md
    • Updated the minimum CMake requirement from 3.16 to 3.25.
    • Revised the working directory instruction for CLion to point to the build output directory, clarifying that game assets are copied there automatically.
  • docs/build-guide.md
    • Added a new comprehensive guide detailing build system mechanics, supported scenarios (WSL, CLion, Windows native), setup instructions, performance notes, and directory layouts for each environment.
  • src/CMakeLists.txt
    • Moved .NET ClientLibrary and ConstantsReplacer build logic out of the if (MSVC) block to enable cross-platform compilation.
    • Implemented find_program to prioritize dotnet.exe (for Windows/WSL interop) and fallback to dotnet (for Linux).
    • Added a warning message if a Linux dotnet is found but the target is Windows, as cross-OS Native AOT is not supported.
    • Introduced a mu_native_path CMake function to convert Linux paths to Windows UNC paths (wslpath -w) when dotnet.exe is used from a Linux host, ensuring correct path interpretation by MSBuild.
    • Defined MU_NUGET_CACHE_DIR as a cache variable, defaulting to ${CMAKE_SOURCE_DIR}/.nuget, to configure the NuGet package cache location.
    • Updated dotnet publish and dotnet build commands to use the dynamically found DOTNET_EXECUTABLE and the newly translated native paths for project files, output directories, and environment variables.
    • Added a warning if the .NET SDK is not found, indicating that the Client Library will not be built.
    • Modified target_link_libraries for the Main target to conditionally link opengl32 and dwmapi after imgui for MinGW builds, addressing linker order sensitivity.
Activity
  • A bot provided an initial summary of the pull request, highlighting key changes such as cross-platform .NET build support, WSL interoperability, NuGet cache configuration, MinGW linker order fix, and .gitignore updates.
  • The author issued multiple /gemini review commands, requesting automated code reviews.
  • The author issued a /gemini summary command, requesting an updated summary.
  • A bot suggested simplifying path conversion logic for the client library by initializing native path variables before conditional wslpath calls.
  • A bot suggested a similar simplification for the ConstantsReplacer path conversion logic.
  • A bot identified a typo in README.md, suggesting Visual Studio 2022 instead of 2026.
  • A bot recommended encapsulating the wslpath conversion logic into a CMake macro to reduce code duplication, particularly for the ConstantsReplacer target.
  • A bot suggested making the opengl32 and dwmapi linking conditional for MinGW only, to avoid redundant linking for other toolchains.
  • A bot pointed out an incorrect imgui submodule path in a git config command example within docs/build-guide.md.
  • A bot advised adding a success check for the wslpath command within the mu_native_path macro (or function) to improve robustness and provide clearer error messages.
  • A bot recommended converting the mu_native_path macro to a CMake function for better variable scope management, given the project's CMake version requirement.
  • A bot queried the meaning of "Claude Code" mentioned in the new build guide documentation, suggesting clarification for external users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant