Task to ensure multiple platform csproj files are kept in sync #216

Closed
Haacked opened this Issue Nov 5, 2013 · 18 comments

Comments

Projects
None yet
6 participants

Haacked commented Nov 5, 2013

Ok, this is a tricky one to describe, but it solves a real problem with multi-platform development that no other CI framework does. And I feel like F# is well suited to it.

Take a look at this PR of Octokit.net: octokit/octokit.net#168

So we have the following project files that should all pretty much have the same project files:

  • Octokit.csproj
  • Octokit-NetCore45.csproj
  • Octokit-Mono.csproj
  • Octokit-MonoAndroid.csproj
  • Octokit-Monotouch.csproj

So when I add one to Octokit.csproj, I need to add it to all the others. However, if I forget to, oftentimes, nothing will break because it's an error of omission.

So I'd love a task that would allow me to provide a list of projects that should be treated as a group and would break if we forget to add a file to one that belongs in the other.

Better yet, if the task could simply add them. Then I could run the build locally and commit that change.

But there's one wrinkle here. Sometimes a file that belongs to one project really doesn't belong to another because of platform differences. So we'd need a way to provide some exceptions.

Member

forki commented Nov 5, 2013

What you need is a better project system ;-)

That said: We could write a bit of code (directly as a target in the octokit build script) which checks if all files with a given file pattern which are in the Octokit folder are also found in the other folders.
Exceptions could be marked with a special suffix "Only". So you could name a file "TouchAPI.MonoOnly.cs"

Target "CheckFiles" (fun _ ->
     // TODO: fail if file structure is incomplete
)
...

"CheckFiles"
==> "BuildApp"

This could be run from the console with ".\build CheckFiles" and will also be run before the "BuildApp" target.

Member

ovatsus commented Nov 5, 2013

I have a similar problem in FSharp.Data, with the FSharp.Data.fsproj, FSharp.Data.Portable.fsproj, FSharp.Data.Silverlight.fsproj, etc., Usually the build will fail if there's something wrong, but not always. If you do add a task for this, also make sure to check the file order for .fsproj files, that's the thing I screw up more often

Member

forki commented Nov 5, 2013

Ok if I read this correct we want to analyze the fsproj and csproj files and not the folders.

Haacked commented Nov 5, 2013

What you need is a better project system ;-)

I've been telling the Visual Studio team this for years. Wildcard support would make this problem go away.

Ok if I read this correct we want to analyze the fsproj and csproj files and not the folders.

Yes! Check out the Octokit directory here: https://github.com/octokit/octokit.net/tree/master/Octokit

Notice we have several .csproj files. The project files point to the same set of files. When I add a new file to Octokit.csproj, the file gets added to that directory and as an entry to Octokit.csproj. But then I have to go edit all the other .csproj files to recognize this new file. This is a pain as you can see in this commit: octokit/octokit.net@15b736c

Member

forki commented Nov 5, 2013

@mavnn IIRC you did some stuff to read and write *sproj files in https://github.com/mavnn/NuGetPlus is that correct?

Maybe we can reuse this.

Contributor

MorganPersson commented Nov 5, 2013

Are we talking about only compilable items in fsproj/csproj or also embedded resources and "other files" (like app.config) ?

Haacked commented Nov 5, 2013

Other files too, but I'd be satisfied with just compilable as a first cut. 😄

Contributor

mavnn commented Nov 6, 2013

@forki All the NuGetPlus project file manipulation happens via this class: https://github.com/mavnn/NuGetPlus/blob/master/NuGetPlus.Core/ProjectSystem.fs which is basically a direct port of the NuGet class of the same name but public and in F#. Feel free to steal it as the beginning of a helper if you want!

Having said that, the more I use the stuff in Microsoft.Build.Evaluation the more I wonder whether you aren't better off just treating the file as a piece of XML and have done with it - I'll leave that to your better judgement!

Sorry for the slow reply, I was hoping to be more helpful - but the actual paid work thing is a bit manic at the moment.

Member

forki commented Nov 6, 2013

Mhm the ProjectSystem.fs looks good. Maybe we use this. Thanks

forki referenced this issue Nov 6, 2013

Merged

Project system #220

Member

forki commented Nov 6, 2013

Mhm. This requires a dependency on Nuget.Core and Microsot.Build

I think that's too much, but it's a start

@forki forki added a commit that referenced this issue Nov 6, 2013

@forki forki Try to make the project system as dumb as possible we'll use TDD and …
…implement only what we need - references #216
345b6c5
Contributor

MorganPersson commented Nov 6, 2013

I have a version can sync "compile" nodes in visual studio project files using xml parsing.

Member

forki commented Nov 7, 2013

@Haacked It's reporting missing files for C# projects see octokit/octokit.net#192 for usage in octokit.
@ovatsus It's also reporting unordered files for F# projects. Please tell me if it works for you.

Closing this now. We can reopen if needed.

forki closed this Nov 7, 2013

Contributor

bentayloruk commented Nov 8, 2013

Steffen. This is ace! Thanks. I had an fsx script that generated XML for this, but FixMissingFiles is much better!

Member

forki commented Nov 9, 2013

@bentayloruk please tell me if it works for you.

Contributor

bentayloruk commented Nov 9, 2013

@forki yes, this works for me. I'm using FixMissingFiles alone in a script I run manually. I then have CompareProjectsTo run in the main build script to warn me if I failed to run the update. I've left this manual step so that I remember to review the code for framework specific bits.

Member

forki commented Nov 9, 2013

Ah it's nearly the same workflow as in Octokit. Next step is to autofix the
duplicates
Am 09.11.2013 16:55 schrieb "Ben Taylor" notifications@github.com:

@forki https://github.com/forki yes, this works for me. I'm using
FixMissingFiles alone in a script I run manually. I then have
CompareProjectsTo run in the main build script to warn me if I failed to
run the update. I've left this manual step so that I remember to review the
code for platform specific bits.


Reply to this email directly or view it on GitHubhttps://github.com/fsharp/FAKE/issues/216#issuecomment-28129991
.

Member

forki commented Nov 10, 2013

The "FixProjectFiles" task adds missing files and removes duplicates

dtchepak referenced this issue in nsubstitute/NSubstitute Aug 30, 2016

Open

Sync netcore and .NET projects #246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment