r/dotnet • u/YangLorenzo • Jul 31 '23
Opinions on MSBuild from Java Maven Users: Why do C# Programmers Seem Less Concerned About Build Tools?
I would like to ask people who have experience using the Java Maven build tool, what are your thoughts on MSBuild? I've noticed that C# programmers seem to be less concerned about build tools. In the Java world, there's Ant, which was later replaced by the improved Maven, and now we have Gradle. However, C# has been sticking with MSBuild all along. As far as I know, before .NET Core and the introduction of SDK-style projects, MSBuild was quite verbose, comparable to Java's Ant (which was introduced in 2000), and it was only after the advent of SDK-style projects that it could be compared to Java's Maven (which was introduced in 2004). This makes me feel like the build system in the C# ecosystem is lagging behind. Despite this, C# programmers don't seem to be bothered by it. Is it because Microsoft has effectively hidden the complexities from them?
Is MSBuild more complicated than Maven? (not just lengthy) And is the documentation worse than Maven? I've seen the authors of IKVM projects describe their MSBuild experience as hell. I was under the impression that Maven was merely lengthy, whereas modern MSBuild is challenging, and the complexity is hidden in layers (dotnet build, Visual Studio) .
8
u/jozefizso Jul 31 '23
MSBuild just works. It gets job done. I am not sure what is here to discuess? Yeah, Java has different build system. As any other programming language out there.
5
u/bloudraak Aug 01 '23
I worked on a codebase that was 3 million lines of C# (with comments excluded). A majority of it was built using MSBuild.
I also supported release engineering for other ecosystems, including Java and find these comparisons to be meh.
It can be complicated as F. However, it provides extension points which greatly simplifies customization, to the point where the consumer has an incredibly simple MSBuild file. It’s also great at providing sensible defaults. There was NAnt at some point, and these days we have Cake. I hated MSBuild when it came out, but once I started using it on very large projects, fell in love with it.
There’s only so much a build system has to do before it’s feature complete. Many of those problems were solved decades ago.
Most folks never really get into the nitty gritty of build systems, nor should they. We want folks to focus on their apps.
2
u/TsyctheIsAMispelling Aug 02 '23 edited Aug 02 '23
I spent 20 years working in a number of Microsoft shops and, like many other commenters, never even thought about my build tools. Before CI/CD I used the Publish command to build deployable packages and more recently with Azure Pipelines, you just add the build tasks and off you go. Build complexities and dependency management are well handled and hidden from the developer... as they SHOULD be.
Developers/engineers don't get paid to build build and deployment mechanisms, we get paid to deliver features and functionality. The more time we dedicate daily to thinking about build and deploy the less time we are spending actually delivering those features and functionality and I don't see how that makes any sense.
I recently started working for a large company with an aging codebase and the culture shock of building and and deploying dotnet code (I refuse to call this horror story CI/CD) with Maven, Gradle, etc .. was like being punched in the face, daily while trying to learn the code, the processes, oh, and the line of business I support. I don't understand why there needs to be such complexity outside of the dotnet world but my experience (10 months and counting) has shown me nothing but.
My team is going to faint when I show them a mono-repo project in Azure DevOps where we have full work item tracability from feature request to release per environment, database deployments automated in the pipeline and everything happening without one person needing to write a custom Gradle, Maven, Perl, powershell or shell script to do it. Not 1. Oh and gated (permission required) environment releases at the push of a button or upon automated tests passing...all out of the box with Azure Pipelines.
Sorry, quite a rant here but I've spent the past 10 years getting used to spending my days writing better features and functionality because we had automated our CI/CD. To step away from it has brought me so much pain. This post is like what Eric Draven does to Top Dollar on the roof of that church at the end of The Crow. 10,000 hours of pain, all at once, all for you... 😄
100
u/Kant8 Jul 31 '23
It just works as expected, so nobody cares basically.
Old style was a bit cumbersome cause you had to mention each new file there, so lots of edits. Now any project is basically red flag on PR, cause you either did something with build (done usually once in a lifetime), or touched dependencies (done rarely and only with prior discussions).
For ones who for some reason can't stand msbuild, Nuke exists, however I didn't find there anything worth for me to even try migrating. 99% of my project files contain only target framework basically, and executables one where bootstrapped long ago and everything complex is done in CI/CD pipeline anyway.
72
u/[deleted] Jul 31 '23
MSBuild is harder to customise but you rarely if ever need to customise anything. Everything always just works. All you need in your MSBuild config is chose which solution to build and on which configuration.
So the answer to your question is: because we don’t need.
But your question really should be “why are Java build tools such a clusterfuck?”
49
u/tonyenkiducx Jul 31 '23
I've worked with Microsoft tools since Visual Interdev and I've never once had to touch any build tools. You just hit the build button and a program pops out the other end. Why would I want to complicate that process?
62
u/flanker278 Jul 31 '23
Coming from a java background this is a really good feature of dotnet. You never have to think on your gradle and maven configs it just works.
19
u/Due_Raccoon3158 Jul 31 '23
As someone who works with both at my job, Java is far more complex when it comes to building. .NET just works and I don't need to mess with it. It's one of the many reasons why I like .NET much more than Java.
13
u/bigtoaster64 Jul 31 '23
It's not that we care less. It just works as expected. So we don't waste time configuring and reengineering everything every couple years.
12
u/yeusk Jul 31 '23
Sometime with old projects i had to find the correct msbuild options to compile it from the command line.
But the tools just works. That is why people don't talk about them.
I also think the Apache tools are... suited for the apache project and overkill for many java teams.
12
u/[deleted] Jul 31 '23
Honest question. What is MSBuild? I just type "dotnet build". Is it using MSBuild behind the scenes?
11
u/vodevil01 Jul 31 '23
Because they just works 🤷
9
u/tarranoth Jul 31 '23
I have had to tinker with msbuild a bit for c++ projects, but for C# I never really had to do much with it. What complexities are even worth considering? Sometimes you might want to copy some metadata for your build but honestly you really don't want to mess with build systems too much before it becomes a mess nobody understands.
9
u/olivegardenitalian27 Jul 31 '23
I've setup a lot of CI/CD pipelines over the years for my .net projects and I have to say it's only gotten easier with time. At one point I was using Cake but honestly these days it feels unnecessary for most situations. These days it's typically a small yaml file which effectively just calls dotnet test, dotnet publish. Maybe some sonarqube and dependency vulnerability checkers but it usually doesn't take more than 15 minutes through azure DevOps UI to build and then you're good to go. I haven't had to directly mess with msbuild in years. Like most have said it generally just works.
9
u/Jazzlike-Coyote3387 Jul 31 '23
my career's been java --> Dotnet --> java. Currently I find myself wanting to curse maven out almost daily. MSBuild and even how easily packaging integrated in when core came out is easy to take for granted
14
u/Recent_Science4709 Jul 31 '23
I’m not a compilation enthusiast, I focus on what I need to, to deliver my work.
Not sure why I should worry about what happens under the hood if the resulting assembly is performant, and the build doesn’t take forever.
I use gradle in the context of android studio builds because I have to reverse engineer existing mobile apps. I have a 16 core machine and it’s slow AF
9
u/ChessMax Jul 31 '23
Never touched msbuild during c# and unity development somehow. But worked with ant and Gradle. And Gradle is super bad for me. Even ant wasn't that bad.
7
u/chipmunkofdoom2 Jul 31 '23
Personally, I hate that open source software is this way. I hate that there are 3 - 4 Apache projects that do basically the exact same thing in nearly every software discipline. I'd rather there be one tool that is stupid easy for the 9,999 out of 10,000 who just want the thing to work reasonably well.
For the 1/10,000 who needs to do something very specific, there should be a way for that person do do what they need. But I don't think the 9,999/10,000 should have to know any of those advanced settings unless they want to.
6
u/beth_maloney Jul 31 '23
MSBuild has support for csproj and NuGet. It'll take care of a lot of the build process for you. I've used Nant with CSC before and it was absolutely terrible compared to msbuild.
6
u/snakkerdk Jul 31 '23
Solution files (sln) are a bit meh format wise, but you can literally write out the csproj fikes by hand, they are so easy to work with, and relatively simple.
6
u/Deranged40 Jul 31 '23
Ironically, it was the build system in Java that still hasn't caught up and has lagged behind this entire time.
My code builds, my unit tests pass, then my integration tests pass. Benchmarks are still great. What's to change?
Just tell MSBuild which project and which configuration you wanna use and wait for the green light. It's not Java - it doesn't have to be complicated for no reason.
5
u/ConscientiousPath Jul 31 '23
Because it generally doesn't bite us to ignore them entirely. Most projects just use the defaults, which are setup for you when you install VS.
How so? What features does it lack? Just because MS hasn't thrown out MSBuild and introduced something completely new like the Ant->Maven->Gradle switches doesn't mean they haven't been adding new features. MSBuild from Visual Studio 2022 is not the same as MSBuild from VS2005, but they're backwards compatible with old project files so devs don't really have to worry about it.
My Maven experience is limited, but I would say they're similar if you really dig into their guts. Most C# devs would probably say MSBuild is more simple just because they've never actually needed to customize it.
MS reference documentation are generally very good and well maintained--the information is all there. That said, figuring out MSBuild may be slightly more difficult than Maven for some things simply because fewer people customize MSBuild to the same extent as they do with Maven and there are fewer 3rd party articles about doing it as a result. But Maven has been quite complex and annoying when I've had to use it, so I can't say either is clearly worse.
3
u/jayd16 Jul 31 '23
DLL hell is worse than jar hell because of native DLLs and worrying about that but I would still say MSBuild is much more simple.
Nuget being the artifact repo only and separate from the build system also seems to simplify things overall compared to Java. Gradle is taking over and Maven is now the old build system but the current artifact repo.
Gradle itself is very powerful but feels overengineered.
3
u/No-Refuse6609 Dec 18 '23
Those who claim that "it just works as expected" probably haven't encountered anything beyond a "Hello World" scenario.
MSBuild still struggles to properly manage transitive dependencies, a fundamental task for any modern build tool.
There was a request made in the Developer Community to address this basic functionality. Although it was marked as completed, nothing seems to have been resolved. The bug report has been there for almost 3 years now, with comments indicating that there is "no good solution"!
Having used Maven for many years, I've never encountered such embarrassing issues.
2
u/d3risiv3sn0rt Jul 31 '23
Generally msbuild is great but if you need to do something with scripting, css, or file copying it can get arcane figuring out what is needed. It’s very capable but I dread when I have to post process a file and there is not a well documented process for doing it. That is not to say gulp, etc are not arcane either when you get into a corner case.
These days I find myself doing most of the web stuff before or after msbuild in a bash script and that makes things easy in the ci/cd pipeline.
My biggest dislike is xml. Ms ditched xml for config files in core, but didn’t do that for the build process. That was probably for compatibility or someone just said it was still a capable format. XML namespaces left visible trauma in the aughts.
Overall it does the job well particularly if you are not doing something really complex. 4/5 would recommend.
2
u/denzien Jul 31 '23
All I do is hit F5 or F6. If I didn't write the command line CI/CD scripts, the fact that I'm using msbuild would barely even be on my radar.
2
u/voroninp Aug 01 '23 edited Aug 01 '23
We have MsBuild as a foundation + .net sdk CLI + Psake/Fake/Cake/Nuke.
NuGet packages can transparently add build tasks. So yes, in most cases it just works out of the box, but we have tools to extend the behavior.
3
u/maqcky Jul 31 '23 edited Aug 01 '23
I don't fully agree with the "just works" sentiment. It's true that if you just stick to the standard, most of the configurable settings can be done through the IDE and it helps greatly. However, the moment you need to do something slightly different, you have problems.
The documentation is lacking and finding out the order of execution of the steps is complex and tedious. For instance, I added a SASS transformation in a Blazor project. Finding the right spot to convert the SCSS files to CSS, so that the isolation feature picked those files, took me hours.
Publishing nuget packages also had several issues for a while (and I'm talking after they added it to msbuild, it was worse with the manual nuspec files). Things like including the PDBs was far from straightforward. It's true that it has improved in recent versions but there are still some hiccups.
Even managing nuget packages for multiple projects is complicated. You can centralize, manually, the versioning, but then the IDE does not help with updates. This was to arrive a few years back but I haven't seen any announcement in a while.
2
u/[deleted] Jul 31 '23
MSBuild is such a complex and convoluted tool, that nobody in their right mind tries to do much customising with it.
-10
u/wasabiiii Jul 31 '23
MSBuild is hell.
The reason we use it is MS sets our direction and decisions by making it the way things work in tooling and everything else.
Maven is pretty crap too. But there's nobody enforcing it. So Gradle.... Etc...
People try periodically in .net. (Cake). But unless MS adopts it, it goes nowhere.
3
u/[deleted] Jul 31 '23
[removed] — view removed comment