Dealing with Multiplatform Project Files
Octokit.net targets multiple platforms. This involves a large risk to my sanity. You can see the general approach here in the Octokit directory of our project:
Mono gets a project! MonoAndroid gets a project file! Monotuch gets a project file! Everybody gets a project file!
Each of these projects references the same set of
.cs files. When I
add a file to Octokit.csproj, I have to remember to add that file to the
other four project files. As you can imagine, this is easy to forget.
It’s a real pain. So I opened up a feature request on FAKE, the tool we use for our build (more on that later) and asked them for a task that would fail the build if another project file in the same directory was missing a file from the “source” project file. I figured this would be something easy for F# to handle.
The initial response from the maintainer of FAKE, Steffen Forkman, was this:
What you need is a better project system ;-)
This problem (along with so many project file merge conflicts) would almost completely go away with file patterns in project files. I’ve been asking for this for a long time (I asked the Visual Studio team for this the day I joined Microsoft, or maybe it was the first month, I don’t recall). There’s a User Voice item requesting this,go vote it up! (Also, go vote up thisplatform restriction issuethat’s affecting Octokit.net as well)
In any case, sorry to say unlimited chocolate fountains don’t exist and I don’t have the project system I want. So let’s deal with it.
A few days later, I get this PR to octokit.net. When I ran the build, I see the following snippet in the build output.
Running build failed. Error: System.Exception: Missing files in D:\Octokit\Octokit-MonoAndroid.csproj: Clients\OrganizationMembersClient.cs
That’s telling me that somebody forgot to add the class
OrganizationMembersClient.cs to the
Isn’t open source grand?
A big thanks to Steffen and other members of the FAKE community who pitched in to build a small but very useful feature. In a follow-up post, I’ll write a little bit about why we moved to using FAKE to build Octokit.net.
I opened an issue to take this to the next step. Rather than just verify the project files, I want some way to automatically modify or generate them.
FAKE just got even better with the new
FixProjects task! For now,
we’ve added this as an explicit command.
Over time, we may just integrate this into the Octokit.net build directly.