New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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.

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 5, 2013

Member

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

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.

@ovatsus

This comment has been minimized.

Show comment
Hide comment
@ovatsus

ovatsus Nov 5, 2013

Member

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

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

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 5, 2013

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@Haacked

Haacked 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

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

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 5, 2013

Member

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

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.

@MorganPersson

This comment has been minimized.

Show comment
Hide comment
@MorganPersson

MorganPersson Nov 5, 2013

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@Haacked

Haacked Nov 5, 2013

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

Haacked commented Nov 5, 2013

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

@mavnn

This comment has been minimized.

Show comment
Hide comment
@mavnn

mavnn Nov 6, 2013

Contributor

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

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.

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 6, 2013

Member

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

Member

forki commented Nov 6, 2013

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

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 6, 2013

Member

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

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

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 added a commit that referenced this issue Nov 6, 2013

@MorganPersson

This comment has been minimized.

Show comment
Hide comment
@MorganPersson

MorganPersson Nov 6, 2013

Contributor

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

Contributor

MorganPersson commented Nov 6, 2013

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

forki added a commit that referenced this issue Nov 7, 2013

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 7, 2013

Member

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

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 forki closed this Nov 7, 2013

@bentayloruk

This comment has been minimized.

Show comment
Hide comment
@bentayloruk

bentayloruk Nov 8, 2013

Contributor

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

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!

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 9, 2013

Member

@bentayloruk please tell me if it works for you.

Member

forki commented Nov 9, 2013

@bentayloruk please tell me if it works for you.

@bentayloruk

This comment has been minimized.

Show comment
Hide comment
@bentayloruk

bentayloruk Nov 9, 2013

Contributor

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

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.

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 9, 2013

Member

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//issues/216#issuecomment-28129991
.

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//issues/216#issuecomment-28129991
.

@forki

This comment has been minimized.

Show comment
Hide comment
@forki
Member

forki commented Nov 9, 2013

@forki

This comment has been minimized.

Show comment
Hide comment
@forki

forki Nov 10, 2013

Member

The "FixProjectFiles" task adds missing files and removes duplicates

Member

forki commented Nov 10, 2013

The "FixProjectFiles" task adds missing files and removes duplicates

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