feat(bau): add msbuild support by PowerUser64 · Pull Request #68 · Zeioth/compiler.nvim · GitHub
Skip to content

feat(bau): add msbuild support - #68

Draft
PowerUser64 wants to merge 18 commits into
Zeioth:mainfrom
PowerUser64:msbuild-init
Draft

feat(bau): add msbuild support#68
PowerUser64 wants to merge 18 commits into
Zeioth:mainfrom
PowerUser64:msbuild-init

Conversation

@PowerUser64

@PowerUser64 PowerUser64 commented Feb 19, 2025

Copy link
Copy Markdown

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 that adds windows support in #58, because 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.

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
Copy Markdown
Author

@thedeany

Copy link
Copy Markdown

@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!

@PowerUser64

PowerUser64 commented Apr 17, 2025

Copy link
Copy Markdown
Author

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