Thoughts on project files
I missed last night's ASP.NET Community Standup on account of being shattered after a long day and falling asleep. Then I checked Twitter on the train this morning and discovered that the .NET world had, apparently, been burned to the ground by marauding Microsofties (again). It seemed to have something to do with project files, JSON vs XML, and suchlike.
Finally, lunchtime happened and I could watch the recording of the standup, and I got to understand what everyone was on about. In case you've missed it:
The TL;DR history
- In the beginning, there was
make, and Gates did not own
make, so Gates said "Let there be MSBuild" and there was
*.*projfiles from Visual Studio as its inputs, which were formed of terrible XML, and verily it was impossible to use without a Visual Studio license.
- And Gates looked upon the Visual Studio revenues and saw that they were good.
- And much time passed, and Gates ascended into a Foundation, and the peoples of the Earth began to worship false software development ecosystems.
- Like Node.js.
- And the acolytes at the Church of Gates observed attendances were down, and sought to bring the lost sheep back into the fold.
- Then Lo! a multitude of Scotts gathered unto themselves seven-times-seven likeminded people, and stormed the Temple of GitHub, and freed the Source Code, that the people might partake of it and embrace it and do Pull Requests.
- And the New Code did not use XML, because everybody knows that XML is old and shit, and yea, verily, JSON is where it is at.
- But the acolytes of the New Code did wander in the desert for many years, searching for the Promised Land of Milk and Honey and GoLive Licenses.
- At one point they thought they could see it over the next hill.
- And there was much rejoicing.
- But, alas, it was a mirage, and you shouldn't use it in production.
- Thus after 40 days and 40 nights, the Acolytes of the New Code did stand up and say "Let us New ALL THE THINGS", and it was so.
- And when all the things had been made new, a Scott wrote a letter unto the people
of Corinth, saying: "we are working to merge the capabilities of .xproj/project.json and .csproj project systems into a single project system based on MSBuild".
- And the people did respond "WAT?"
- And the Head Acolyte did clarify that the
project.jsonwas not The One True Way.
- And that The One True Way did, in fact, have quite a lot of XML in it after all.
- And there was much wailing, and gnashing of teeth, and rending of clothes, and tearing of hair, and stuff.
My initial reaction
My more considered reaction
Look, I'm not happy about this, I hate XML as much as anyone, especially XML with Schema in it, but I don't think it's as bad as everyone's making out. Probably. It seems like they're planning to keep the JSON format for NuGet package references, and the whole thing of having to put all the files that were part of the project into the project file instead of, you know, the directory, seriously, how hard is this stuff has gone away, because it turns out that MSBuild could handle globs all along and it was just Visual Studio that was stupid.
And the command line tooling is going to be able to do all the complicated stuff, or something, so it doesn't really matter that trying to make a tiny change to the
.csproj file in a text editor is going to be like digging through broken glass in a rusty bucket of vinegar looking for an angry sea urchin.
It's this last thing that seems to have people upset, this idea that we should be maintaining project files by hand-editing them, but is that really better? Do you install NPM packages by editing
package.json? No, you
npm install --save.
The fact is, we've gone from DNX, which just used Roslyn to compile a bunch of C# files into an in-memory assembly at runtime, to .NET Core, which produces an on-disk assembly (and can even AoT-compile that to a native, statically-linked binary that requires no external runtime). Doing that requires a lot more metadata about architectures and environments and what-have-you, and yes, you could encode all of that in JSON, but it would be big, complicated JSON and not that much more fun to edit, if we're honest.
eval function. And then it turned out you shouldn't do that anyway, because security. The only reason it's become so popular as a configuration format is Node.js, which speaks JSON natively.
After watching the relevant part of the standup video again, I am remaining cautiously optimistic that any parts of a project's configuration for which hand-editing does make sense—for example, packaging or runtime configuration—will be kept out of the XML project files and managed separately.