Skip to content

feat(bau): add msbuild support #68

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

PowerUser64
Copy link

@PowerUser64 PowerUser64 commented Feb 19, 2025

I've written this integration with compiler.nvim for MSBuild to ease the pain of having to use MSBuild on windows. I've based this work on @Gaweringo's work on adding windows support in #58, since MSBuild only runs on windows. I can change this and/or rebase pretty easily if needed, since I just have one commit here.

This integration provides the following functionality

  • execute Build, Run, Clean, and sequentially Build and Run targets for msbuild projects
  • supports multiple project files (.sln) in the same directory (this jkhappens sometimes)
  • auto detects build configurations (debug, release) based on the contents of each .sln file
    • currently, release configurations are removed from the list (if there are others), since compiler seems to prefer to present only one type of build configuration in other cases (eg. plain .cpp file only has one build type). I can remove this behavior if this isn't the case, although it makes the menu a bit messier to use.

Also of note is that msbuild provides LOTS of default targets for each project (there are 438 in one project I have), so I'm only scratching the surface by including the build, run, and clean targets. There are others (like Rebuild), that could potentially be useful too, but so far I've only added these ones so far to bring parity with the default C/C++ configuration. I could add others if it'd be welcome.

The only thing this requires is that msbuild.exe be accessible through the user's PATH, which it isn't the case by default on windows. It'd be possible (and likely not very hard) to make some basic logic to find the executable on the filesystem with globing (more about this on SO), but it somewhat feels like stepping outside the scope of this plugin since it adds some potential for variability. I can write some documentation on the wiki to explain this PATH stuff if needed.

I'm marking this as a draft for now since #58 is unmerged and I have code from it. Also, I'd like to use this for a bit longer before it gets merged (maybe two weeks from now at most). There could be a bit more tweaking to do with the default list of targets.

Also, thank you to @Gaweringo for all your work on adding windows support to begin with! I might not have attempted this if it weren't for that.

@PowerUser64
Copy link
Author

I should also note, I haven't written much lua code before, so there's a chance I made some rookie mistakes or wrote things in a way that could be improved. Please don't be afraid to say so if this is the case anywhere!

@thedeany
Copy link

@PowerUser64 I've pinned your repo in my config to test this out, but I'm not having much luck. I have a solution with upwards of 70 .csproj projects in it. When I open Compiler and choose to build, it reports

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.

I was hoping it would build the project in which the current file resides. Is this what should be happening? Or do I need to specify the project somehow? I've tried running the build command with a .csproj as the active buffer as well to no avail.

Any help would be appreciated. Thanks for all your work on this!

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.

3 participants