TheSwamp

Code Red => .NET => Topic started by: CADbloke on October 02, 2015, 07:58:41 AM

Title: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 02, 2015, 07:58:41 AM
Edit: Oct 31, 2015. - Name change, Github repo name is changed.

Code Linker will only work in Visual Studio. It is not a build process, it is a way to share the same code between C# projects.

All Code Linker does is adds links to existing code files into a target csproj. No file is copied, no source code is parsed. The original csproj file is mined for its source code <Include=...> things and that information is used to add links to the target csproj file. That's all. It ends there. The target csproj is all it touches. It automates the add a file as a link to a C# project (https://msdn.microsoft.com/en-us/library/windows/apps/jj714082(v=vs.105).aspx) process. That link explains it really well, and also some of the reasons you would do this.

The code repo is at https://github.com/CADbloke/CodeLinker

There is an Illustrated example at https://github.com/CADbloke/CodeLinker/wiki/Illustrated-Example

There's an extensive readme (https://github.com/CADbloke/CodeLinker/blob/master/readme.md) there so I won't duplicate it here.



...original text for posterity's sake (posterior being a synonym for "ass" which is what I made of myself)...

(edit Oct12, 2015)  Scroll down to this post (http://www.theswamp.org/index.php?topic=50202.msg553839#msg553839), that's where I started to make sense. I will post a better description when I have had enough sleep.

...
I'm having another crack at this at https://github.com/CADbloke/CodeLinker

This time around I'm focusing on propagating source code to destination Projects which control all their own build settings. Apparently some (all) of us though that 72 builds in one project was a little unmanageable </YesItWas>.

(edit Oct12, 2015)  No, I lied, I am creating links to existing source code. The source project is mined for code links and these links are written to the target project.

There's an extensive readme (https://github.com/CADbloke/CodeLinker/blob/master/readme.md) there so I won't duplicate it here. I'd love to hear any thoughts, suggestions, WTFs.

For those unaware of the history ...
http://www.theswamp.org/index.php?topic=41868.msg497509#msg497509
http://www.theswamp.org/index.php?topic=49039.msg541744#msg541744
http://www.theswamp.org/index.php?topic=49961

are just a few.

It's like looking at any of your work from years ago ... WTF? Hopefully this one will have a few less WTFs / Minute (http://www.software.ac.uk/blog/2011-09-02-wtfsmin-indicator-code-quality)
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 02, 2015, 09:23:03 AM
Git - Merging from a template project - no subdirectory
http://stackoverflow.com/questions/9106387/git-merging-from-a-template-project-no-subdirectory
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 02, 2015, 11:10:46 AM
Generate C# project using CMake
http://stackoverflow.com/a/15418074
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 05, 2015, 06:29:54 AM
Git - Merging from a template project - no subdirectory
http://stackoverflow.com/questions/9106387/git-merging-from-a-template-project-no-subdirectory

This has potential but requires good Git-fu. Also, Google "csproj merge conflict"

Generate C# project using CMake
http://stackoverflow.com/a/15418074
I might be missing something there but keeping changing source code in sync with that doesn't sound easy. Can you elaborate ?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 05, 2015, 09:44:21 AM
Git - Merging from a template project - no subdirectory
http://stackoverflow.com/questions/9106387/git-merging-from-a-template-project-no-subdirectory

This has potential but requires good Git-fu. Also, Google "csproj merge conflict"

Generate C# project using CMake
http://stackoverflow.com/a/15418074
I might be missing something there but keeping changing source code in sync with that doesn't sound easy. Can you elaborate ?
`Git-fu' lol (that's made me laugh) it's just one command git remote add.... I googled the csproject merge conflict but I have zero context (I don't have any reliance on the VS IDE) as to what it is about. Is this something you can live with? This option fits your criteria the best and offers you the ability to update or not (Very flexible).
If you're worried about the git-fu you can build a few batch scripts to checkout and update from the template.

The second option is a bit of an enigma for me (the VS stuff confuses me; I don't use it and the VS IDE holds your hand too much) but how I understand the CMake option is that your template project is referenced in place (no copying of files to new projects).
This option is nice but I have to warn you though, it would be far easier to learn Git better then to pick up CMake. CMake is a beast (and a fickle one at that)! ...don't get me wrong, I love it, but man can it be a pain to set up your project the way you want to sometimes.

I recommend setting up a quick test of the first one (git option) and see how you like it.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 05, 2015, 08:10:31 PM
Thanks of the follow-up. The CMake approach looks like a departure for Visual Studio's csproj projects? That's not a direction I'm currently interested in going.  I really like Visual Studio hence my latest approach to clone the code between projects inside the IDE, if you change the code in one project it changes for all of them, although you need to add and remove any "universal" files from the original project which could be a pain-point if you stray from the original source project. The only reason I expect to be editing code in target projects is to fix any differences in code between the various APIs or to fix failing unit tests (after I fix CADtest). I also like seeing in the IDE what code the #if directives are affecting and what API classes are actually being called. Yes, I like having my hand held. :)

If CMake does embrace csproj then it looks a bit like the proliferation of project imports I wrote about at  http://www.theswamp.org/index.php?topic=41868.msg497509#msg497509 which eventually breaks for me because importing a project drags in framework and build settings, References as well as any Nuget package specifics. It also tends to bury things a bit too deeply to quickly make sense of them, especially if I am coming back to something I haven't looked at for quite a while. I have zero experience with CMake so I may be way off the mark here.

The Git approach has potential but does this mean you need to write the code in a project that doesn't compile (gasp! No Intellisense) and juggle Git Remotes. No, not so hard really but I am trying to keep it all "simple". In theory. Your Git approach works for you perhaps, as you said, because you don't work in Visual Studio?

I also wanted a system I can drop in on top of stuff I've already written without breaking it. You never break the source project because it never writes to it, although your code in it will change with various #if directives if your platforms vary widely.

This article: http://haacked.com/archive/2014/04/16/csproj-merge-conflicts/ explains what I mean by .csproj merge conflicts. Understanding what is going on in the csproj files, and keeping an eye on it is important with this approach. They are just XML text files so the differences will be very obvious in commit diffs but you need to know what to expect. Once you've seen a few sets of changes then you will know what looks odd. Also, reverting changes is easy.

I tested Code Cloner with a WPF AutoCAD Project and it worked well, it all came together, looks good in Visual Studio (hey, I care) and builds fine.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 06, 2015, 08:00:41 AM
I'm sorry CADbloke but I am this close to giving up on you. Have you run a test (because I just did)? I'm sorry if that seems rude but I just don't know how you structure your code/projects so you will have to be the one driving this, not me.

CMake is a cross platform build system. That means you can take code and compile it on a windows, Mac, Linux, and Unix machine. You do this by writing a "recipe of how to build" your project. CMake takes that recipe and builds a build system for your platform (so in windows, cmake can build a VS project from your code and recipe. In Mac, it would build an xcode project from your code and recipe. In unix, it would build a Makefile. etc. etc.). Forget CMake, this would work, but it would be too much command line for you (you'd have to type way too much).

Git, just tracks your files. It has nothing to do with your code compiling or not (or Intellisense; that is a feature of your editor/IDE not your code). You can decide to track anything you want; if you want to track csproject or not is up to you and how you structure your template. Visual studio has built in support for Git but it is a really weird experience; you will have to open the command line and type.

Run a test!!
1. Create a template project: "[EX]_VS_Template-Project"
2. Close and create another project: "[EX]_VS_Test-Project-One"
3. Open the command line and add a reference to the previous one: git remote add -f template ../[EX]_VS_Template-Project
4. Merge the template project to your new project: git merge template/master
5. Add template project to your new one (I right clicked on the "Solution '[EX]_VS_Test-Project-One'" in the solution explorer and choose ADD EXISTING PROJECT).

NOTE:
1. Apparently, you can use wildcards in csproject files so I don't know if that helps you at all (with the compile/intellisense statement).
Code: [Select]
<ItemGroup>
  <Compile Include="${DOS_STYLE_SOURCE_DIR}\**\*.cs" />
</ItemGroup>

Now, all that said, this is the hand holding that I do NOT like. -i.e. The directory structure that VS keeps is horrendous! I would go bat-crap crazy trying to look at this all day. I solve this problem and other problems like this in my C++ projects with a combination of a directory structure, and CMake.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 06, 2015, 05:07:56 PM
I'm sorry CADbloke but I am this close to giving up on you.

Perhaps you should. I have no desire to waste your time and if Visual Studio projects don't interest you (or even offend you) then perhaps this topic is not for you. You clearly haven't read the readme at the Github project I pointed to in the first post. My objectives all there - it is clear there (although not so much here) that I want this to work in Visual Studio (https://github.com/CADbloke/CodeCloner#a-workflow-i-just-made-up). I also note how I structure my projects there (https://github.com/CADbloke/CodeCloner#a-workflow-i-just-made-up).

Nor do you seem to have referred to any of the historical posts I linked to. I mention the wildcard usage in C# project files and its fragility both in the Github readme (https://github.com/CADbloke/CodeCloner#code-cloner-by-cadbloke) and in linked posts (http://www.theswamp.org/index.php?topic=49961.msg551703#msg551703). Wildcards are an MSBuild thing, Visual studio tolerates them to a point but doesn't natively embrace them - to the extent that it will enumerate them into individual links if you happen to add a file into the folder tree you linked with wildcards. I can't beging to tell you how much fun this is if you happen to miss it at the time.

Git, just tracks your files. It has nothing to do with your code compiling or not (or Intellisense; that is a feature of your editor/IDE not your code).

Yes, I know, I have this Github thing (https://github.com/CADbloke) and some experience with Mercurial (http://stackoverflow.com/search?q=user:492+[mercurial). My point is that you should be writing most of the code in the original  template project. If that doesn't compile, have SDK references etc. then you are basically coding blind. Yes, you could write the code in one of the target projects but then you need to remember to add, remove, rename, refactor etc in the original template project. Any build settings in the template project will clash with the target projects. I also like Visual Studio's autocomplete, it types faster than me. See also Resharper which holds my other hand.

You hate Visual Studio (you said so) and seem to want to save me from it. Thank you for your concern but I'll be ok. I make no apologies for my lesser calibre in this field (with the possible exception of csproj files) and my affection for Visual Studio's "hand-holding", you clearly have a broader and deeper experience than me in these things. So did Tony Tanzillo and his condescending tone killed a lot of discussions too. I am sure there are plenty of people reading this who won't want to add to the discussion for fear of being made to look stupid. A quick peruse of my post history will show that I have overcome this fear but most have not. The same elitism has also stunted Stackoverflow.com.

As an aside, I have been known to type thing on a command line from time to time. I even once broke a nail doing so.

I will start a new post with a more clearly defined headline, my apologies for the overly ambitious scope I declared in my original headline.

Thank you for your explanation of CMake, that is a much better one than they have on their page.

I do sincerely thank you for your suggestions and help but I will call you out for your tone, your bias against Visual Studio is your problem (not mine) and making me look like a dill is both a community killer and also redundant - I don't need you help on that one ;).

cheers
Ewen
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 06, 2015, 09:24:15 PM
VS doesn't 'offend' me at all. I've used it several times, I just prefer to use my editor and a compiler instead of conforming to an IDE. I've seen both sides of the fence so feel as though I can have an opinion.

Feel free to call me out for any tone you feel you've perceived.

Yes, I have read all the links you provided. I read your read me twice. I do not understand most of the links because we speak different languages. Nonetheless, I am still trying to help. No, I don't have time to read everything nor do I have time to do a bunch of tests or back reading up on for some concept I do not fully grasp yet.

Tony was a little rough at times but he was always very helpful towards me but I've always understood that someone with his abilities was probably very busy so I tried not to read too much into "tone" -I.e tried to take the written word at face value and not read much into it other then help and direction.

Again, I've used VS a few times. I even ported one of my projects for fun. ...I have zero desire to 'save' you from anything (why should I care what you use). I was only trying to give you perspective into my lack VS abilities so you can add salt to any direction/suggestions I offered up and/or added further...*sigh* Good luck.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 06, 2015, 11:23:49 PM
I took Tony's comments in the same way, I miss him around here. I am personally not offended at all by your posts (for exactly the same reasons you were not offended by Tony) but I think some lurkers may be a little more sensitive and thus more reluctant to post their input lest they are shown up. I guess that's a risk anywhere and probably their problem - I personally came here to be wrong and to be corrected. I don't think I'm being clear about this, I just don't want to scare the newbs into silence.

Thank you for your input so far. I certainly don't wish to convey any ingratitude - far from it, I have learned things here and that's what I came for. I think you and I may probably never share common opinions on Visual Studio and CMake and that's a good thing, forums like this need that dissonance and difference of opinion. If you got the feeling I devalued your opinions and experience then I'm sorry, that was not my intention, far from it.

I, personally, would avoid the Git approach simple because I think big project could be a handful to merge consistently. Code Cloner puts all the code in one place. I think I need to clarify in the workflows in my readme that it's a good idea to commit the cloned code right away so you can tell if you accidentally add something local in the middle of it after the fact. It still needs work (it is only early days), I do need to make it check that anything has actually changed before it rewrites the csproj file because the whole reloading recently saved projects gets tiresome pretty quickly.

I think the best demonstration of Code Cloner is to clone it locally, build it a couple of times until it clones into its own .NET 3.5 project and then see what the next Git commit looks like. You will see the lines it has added to the .NET 3.5 project.

As an aside, linking files with wildcards in Visual Studio breaks a lot because of the different file extensions (*.xaml, *.config, *.resx etc) and also the "DependsOn" Attributes, you need that meta information from the original project, well you need it in Visual Studio, it will probably build just fine without it.
Code: [Select]
<ItemGroup>
  <Compile Include="${DOS_STYLE_SOURCE_DIR}\**\*.cs" />
</ItemGroup>

Linking with *.* can create a bit of a mess and you eventually end up with progressively unmaintainable stuff like ...
Code - XML: [Select]
  1. <Compile Include="..\Path\To\ParentFolder\*.*"
  2.         Exclude="..\Path\To\ParentFolder\NotThisOne.cs;..\Path\To\ParentFolder\NotThisOneEither.cs">
  3.   <Link>ParentFolder\%(RecursiveDir)%(Filename)%(Extension)</Link>
  4.  </Compile>
  5. <!-- Visual Studio loves to refactor these things so I always add it as a comment too so I can restore it.
  6.        Source Code repo check-ins are an easy way to spot this when it happens.
  7. <Compile Include="..\Path\To\ParentFolder\*.*"
  8.         Exclude="..\Path\To\ParentFolder\NotThisOne.cs;..\Path\To\ParentFolder\NotThisOneEither.cs">
  9.  <Link>ParentFolder\%(RecursiveDir)%(Filename)%(Extension)</Link>
  10. </Compile>
  11. -->
  12. <!-- This sort of abomination is also possible, if not advisable -->
  13. <Compile Include="..\zSourceCode\**\*.*"       Exclude="..\zSourceCode\Properties\AssemblyInfo.cs;..\zSourceCode\bin\**\*.*;..\zSourceCode\obj\**\*.*;..\zSourceCode\**\*.csproj;..\zSourceCode\**\*.user;..\zSourceCode\**\*.vstemplate;..\zSourceCode\readme.txt;..\zSourceCode\**\*.lsp;..\zSourceCode\**\*.scr;..\zSourceCode\**\*.ico;..\zSourceCode\**\*.txt">
  14.  
  15. <!-- This has an absolute path with a  variable previously declared in this or another .csproj file -->
  16. <Compile Include="$CadExtensionClassesRootFolder$\Common\*.*" >
  17.   <Link>Common\%(RecursiveDir)%(Filename)%(Extension)</Link>
  18. </Compile>

At the end of the day I am trying to find the best way that works for me, I posted it here and at Github in case it helps someone else along the way, or at least helps to clarify why they like their way by showing an alternative they don't like.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 07, 2015, 07:31:36 AM
Too many merges, too often? Now its starting to sound to me like you're building a library (dll) or should be. Failing that you could use a preprocessor to generate code files for you (and update them before you compile). Heck, I have two preprocessors myself (well, only one compiles unless you want to customize the source code of a compiler so you can compile the other one) you could use.

Sounds to me like you are making this far too complicated and you should step back and work on not only your read me but your criteria as well.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 07, 2015, 08:01:33 AM
Found this while surfing this morning.

T4 Tutorial: Creating reusable code generation templates
http://www.olegsych.com/2008/09/t4-tutorial-creating-reusable-code-generation-templates/
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: Jeff H on October 07, 2015, 03:54:57 PM
I do this type of stuff everyday using VIM
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 07, 2015, 04:02:36 PM
I do this type of stuff everyday using VIM

Does Vim have a script to remove my foot from your a55?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 07, 2015, 07:21:06 PM
Sounds to me like you are making this far too complicated and you should step back and work on not only your read me but your criteria as well.
<TLDR>
Um, yeah. I think you got me there. This one is less complicated than my previous efforts but it's still not a "click...next..Yay!" solution. By the time I'm 80 I'll have this nailed. Maybe. The readme definitely needs an edit, it's a midnight braindump.

If all you have in your source project is *.cs files then importing the files with a wildcard into your new project is the easiest solution. Job Done. Ditto if the source project is quite static, nothing much changes. I want a solution that can automatically keep the projects in sync, even if the original source changes radically. I want it to be Visual Studio friendly. I want more coffee.
</TLDR>

Code Cloner is definitely half-baked. Here's the proof (I wrote the following first)...

...you could use a preprocessor to generate code files for you (and update them before you compile)...

That's basically what I want Code Cloner to do, sort of. I want to work with the original files, not proliferate copies all over the place that need to be kept track of and in sync with the original. If I have a bright idea and add it to a target project (because I'm tired and forgot to switch to the original source project) then I want the changes to propagate to all projects - linked files solves that. One version of the Truth. I also want it to work as an easy drop-in on an existing project. You make a call to CodeCloner.exe whenever you want to refresh the target projects. You can check the projects against each other in a text-diff to see what is missing, as a confidence test. As an example, diff the 2x csproj files in the Github project (https://github.com/CADbloke/CodeCloner) after you build them a couple of times, you will see the added lines in the XML and how they compare to the original.

a use case is ...
Well, that was crap. Next!

I still think that, for a Visual Studio addict like me, linked source code is still the most usable way of using the same code multiple times. I, personally, want to look through the code and see what is going on.

I have (more) work to do....after the day job ...after the kids go to bed. Sleep? Meh.

...unless you want to customize the source code of a compiler...
Hey, there's an idea...what could possibly go wrong?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: Jeff H on October 08, 2015, 01:01:39 AM
I do this type of stuff everyday using VIM

Does Vim have a script to remove my foot from your a55?
:2funny:
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 08, 2015, 09:18:27 AM
Okay.

Your criteria/explanations are still a bit jumbled up and I'm still having a hard time envisioning this but I'm getting a better idea of your plan (I think). -i.e. sometimes you are describing a library, and sometimes you're describing a file sync thing, and other times you're describing a processor of sorts.

I think a library (a set of DLLs you can use in your projects) is the best solution:
Pros:
1. No code to copy around.
2. Conforms to the whole .Net concept.
3. Easy to use.
4. Updates are automatic.
5. Quick turn around (fast to get up and running).
Cons:
1. Not sure how VS handles distributions (how to get all referenced DLLs in a package for distribution).

However, if you're dead-set on *not* building and maintaining a library I have some contentions with the processor/file sync thing concepts we'd need to work out later. Namely:
1. What sync method(s) are you planing on, and how are you going to determine which file is outdated?
2. What protocols are looking to sync over (local drive, LAN, WAN)?
3. Are you planning on using compression to keep things small and fast?

But for now we probably start formulating a plan of attack for this thing you have envisioned.

I took a quick look at your github code and I don't really see any "processor" code at all. I mean, I didn't see any sort of tokenizer, lexer, or a sold parser really (I see a bunch of code that looks more procedural in nature than anything). ...I think you should scrap this and start over. Your thing will have to be able to operate on at least a few different file types/languages source code files (C# language), IDE project files (XML).

Assuming the simpler/easier to write/maintain recursive-decent type parser, here's how I think you should start:
1. Build a in/out buffer to handle the file/console read/writes.
2. Pick one of the file types to work on first (C# or XML).
3. Develop a good set of tokens and a rock solid lexer base for handling some parts of the file type.
4. Start building an abstract syntax tree for what you have so far.
5. Start building your base-level and your top-level parsers.
6. Build a main driver.
7. Start building tests.
8. Repeat steps 3-5 and 7 to add to your parser parts until you are able to parse one/all of the file types.

Obviously, you need to work on your criteria and this initial plan will change but this should at least get us speaking the same `language'. I also think XML will kill the recursive-decent type processor plan but we need to start somewhere and I think if you only offer limited abilities in your parser thing you'll be alright.

Sounds to me like you are making this far too complicated and you should step back and work on not only your read me but your criteria as well.
<TLDR>
Um, yeah. I think you got me there. This one is less complicated than my previous efforts but it's still not a "click...next..Yay!" solution. By the time I'm 80 I'll have this nailed. Maybe. The readme definitely needs an edit, it's a midnight braindump.

If all you have in your source project is *.cs files then importing the files with a wildcard into your new project is the easiest solution. Job Done. Ditto if the source project is quite static, nothing much changes. I want a solution that can automatically keep the projects in sync, even if the original source changes radically. I want it to be Visual Studio friendly. I want more coffee.
</TLDR>

Code Cloner is definitely half-baked. Here's the proof (I wrote the following first)...

...you could use a preprocessor to generate code files for you (and update them before you compile)...

That's basically what I want Code Cloner to do, sort of. I want to work with the original files, not proliferate copies all over the place that need to be kept track of and in sync with the original. If I have a bright idea and add it to a target project (because I'm tired and forgot to switch to the original source project) then I want the changes to propagate to all projects - linked files solves that. One version of the Truth. I also want it to work as an easy drop-in on an existing project. You make a call to CodeCloner.exe whenever you want to refresh the target projects. You can check the projects against each other in a text-diff to see what is missing, as a confidence test. As an example, diff the 2x csproj files in the Github project (https://github.com/CADbloke/CodeCloner) after you build them a couple of times, you will see the added lines in the XML and how they compare to the original.

a use case is ...
  • I have a project (or a few, let's stick to one here) in Visual Studio I have written for AutoCAD 2015
  • I decide I want to build a version for, say, BrisCAD with the same code (more or less)
  • I create a new Solution folder in the solution root called "_Builds". I just pulled that name from the same place John just put his foot. Call it anything you like
  • oh, thank you (for nothing!) Visual Studio, now I got to the actual physical folder tree on disk and create the folder in real life. I give it the same name for consistency's sake.
  • In this folder I add / copy / whatever  new csproj Project. Hmm, this sounds a little like "magic just happened, you got that right?". ok, you can
    • copy the existing csproj and hand-delete all the compile stuff then add it as an existing project
    • or you can create a new project of the same type. You will need to make sure the namespaces etc match.
    • Physically copying the csproj may be easier. Actually, something that automagically clones the guts of the project would be easier
  • the new project is the target project. Delete all the code, add the "Clone Zone" placeholders.
  • Add a call to CodeCloner.exe as a post-build process. Or pre-build. I made it post-build in the original project because it actually has to build before it can use itself, it was a chicken/egg thing.
  • Most of your editing is done in the original source project, you're really only tweaking the target(s) to make them compatible with their target platform.
  • ok, I'm bored now, somebody should automate all this crap and get back to me when it works
  • time passes...
Well, that was crap. Next!
  • I have a project (or a few, let's stick to one here) in Visual Studio I have written for AutoCAD 2016 (time passed, for those of you who noticed)
  • I decide I want to build a version for, say, BrisCAD with the same code (more or less)
  • I drop CodeCloner.exe in the Solution root (optional, the .exe can live anywhere, that's up to you)
  • I call CodeCloner.exe init "_Builds", "_Builds" being the folder name I want to use for the new builds
  • New project(s) magically appear under a new Solution Folder. At this stage they are basically clones of the existing project(s).
  • In the target project(s) change the AutoCAD References for BricsCAD references and the .NET framework, if required. I will probably want to  add/remove/change some conditional compilation symbols. Or not, whatever is your preference
  • Fix what broke
  • Ship it. Tests? Meh.

I still think that, for a Visual Studio addict like me, linked source code is still the most usable way of using the same code multiple times. I, personally, want to look through the code and see what is going on.

I have (more) work to do....after the day job ...after the kids go to bed. Sleep? Meh.

...unless you want to customize the source code of a compiler...
Hey, there's an idea...what could possibly go wrong?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 08, 2015, 07:05:22 PM
Okay.

Your criteria/explanations are still a bit jumbled up and I'm still having a hard time envisioning this but I'm getting a better idea of your plan (I think). -i.e. sometimes you are describing a library, and sometimes you're describing a file sync thing, and other times you're describing a processor of sorts.
Yeah, the state of my head this week is not good (https://twitter.com/dontsailbackwds/status/652226937713115137).

Code Cloner...wait, I think it needs a better, more applicable name like "Code Linker"
I don't think I have explicitly said this but ... This will only work in Visual Studio. It is not a build process, it is a way to share the same code between projects.

All Code Cloner does is adds links to existing code files into a target csproj. No file is copied, no source code is parsed. The original csproj file is mined for its source code <Include=...> things and that information is used to add links to the target csproj file. That's all. It ends there. The  target csproj is all it touches. It automates the add existing file as a link (https://msdn.microsoft.com/en-us/library/windows/apps/jj714082(v=vs.105).aspx) process. That link explains it really well, and also some of the reasons you would do this.
I want to work with the original files, not proliferate copies all over the place that need to be kept track of and in sync with the original. If I have a bright idea and add it to a target project (because I'm tired and forgot to switch to the original source project) then I want the changes to propagate to all projects - linked files solves that. One version of the Truth.

Libraries are great. This has nothing to do with libraries, it is all about re-using existing code in a new Visual Studio Project - building the same thing a different way.

Try it, it already works. I just pushed a fix to Github that fixes the issue of refreshing the target project when nothing changed (https://github.com/CADbloke/CodeCloner/issues/2) - it leaves it alone now. Changing code inside linked files does not affect the target project, a link only changes if you add / delete / move a file.

You make a call to CodeCloner.exe whenever you want to refresh the target projects. You can check the projects against each other in a text-diff to see what is missing, as a confidence test. As an example, diff the 2x csproj files in the Github project (https://github.com/CADbloke/CodeCloner) after you build them a couple of times, you will see the added lines in the XML and how they compare to the original.

Here is an illustrated process. I cloned the Github source and opened it in Visual Studio

Note the post-build process (Project - Properties). In this particular instance I put it there because it actually needed to be built for the demo to work. It's also not the standard command line call because I used a macro variable to call the actual EXE. You would normally call CodeCloner ..\..\..\_Builds\CodeCloner-3.5\CodeCloner-3.5.csproj. Putting it in a pre or post build process means it happens automatically, you don't have to think about it.
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeCloner00.png?raw=1])

Note the emptiness of the .NET 3.5 project. Now, right-click the CodeCloner Project in Solution Explorer and click "Build"
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeCloner02.png?raw=1)

Visual Studio will (or not, this may depend on your settings) see the 3.5 project has been tampered with and ask to reload it
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeCloner03.png?raw=1)
Reload it.

Job done. Note the new linked files in the 3.5 project
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeCloner04.png?raw=1)
You can now build the 3.5 project and it will build a .NET 3.5 version of CodeCloner (the original is .NET 4.5.2). You're finished. No, really. Done. That's it.

There are no new files in the 3.5 project. Open the directory on disk and have a look. Have a look at the changes for the next Git commit in the Solution, the only changes are the linked files in _Builds\CodeCloner-3.5\CodeCloner-3.5.csproj
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeCloner05.png?raw=1)


That's all it does. All you need to use it is the EXE. All this Github repo does is builds the exe. I used it as an example of itself which is probably the cause of the confusion here.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 09, 2015, 08:55:15 AM
I'm glad you got your project rolling on the right track.

Next time share a link like the MSDN one early in the conversation (that link would have saved *hours* of my time)! I'm sorry but, as far as I'm concerned, this post deserves the LHTAQTSW (http://www.catb.org/~esr/faqs/smart-questions.html) tag.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 11, 2015, 05:15:57 PM
...this post deserves the LHTAQTSW (http://www.catb.org/~esr/faqs/smart-questions.html) tag.
Agreed. Poor effort on my part. Sorry I wasted your time.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 13, 2015, 05:55:20 PM
Updated the first post (again), added an Illustrated example (https://github.com/CADbloke/CodeCloner/wiki/Illustrated-Example) and updated the extensive readme (https://github.com/CADbloke/CodeCloner/blob/master/readme.md), both at Github.

Let me know if something (everything?) doesn't make sense.

Apologies again (especially to John K) for not making sense previously, it has been that kind of month (https://twitter.com/dontsailbackwds/status/652226937713115137).

I hope you find this useful. I would be thrilled to hear suggestions or alternatives we haven't yet explored.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 14, 2015, 08:04:57 AM
I would add a release to the downloads section of your github project (include help documents).
https://github.com/CADbloke/CodeCloner/releases

I would also remove the "informal" feel to the readme.md writeup. If I stumble on your project, I want to know quickly:
1. What it does.
2. How to get it.
3. Why it does it.
4. What doesn't work about it.
5. How can I contribute.

Another thing you might want to do is to take a look at how other software documents their program. Unix utilities are good examples because they are all individual programs but they all have a common format to their readme's.
Here is the man page (help) for GREP (a basic tool)
http://linuxcommand.org/man_pages/grep1.html

I would also build an installer for people to use. This installer could add the location of CodeCloner to the env path so it can be called via the command line.

Lastly, I hate to suggest this but I would think about changing the name. CodeCloner sounds a bit misleading.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 14, 2015, 05:53:06 PM
Thanks for the feedback John, All your suggestions are good ones. I'll go through them when I get some time. Most of that readme should be separate wiki pages.

I agree with you on the naming - it is misleading. I named it before I wrote it. It should mention reuse ... recycle ... something like that. Clone infers that something is copied and it's not.

This thing needs a complete reboot. Well, there goes the weekend.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 08:37:27 AM
Still working on it.

Here's a teaser ...
(https://dl.dropboxusercontent.com/u/5115091/Swamppix/CodeRecyclerTeaser.png?raw=1)
Everything is draggy-droppy so you can just drag Files, folders etc from Windows Exploder into it. The GUI version recycles the original project(s) and creates the destination project(s) with the right placeholder, source designation(s) and links to the original source code. You can type stuff into the GUI as well, delete rows, mix up tour source folders. It's just a garden-variety editable DataGridView.

Then you add it to a Visual Studio Solution and edit it. Initially it will build exactly the same thing as the source project.

Yes, it also works with VB.NET. At least it's s supposed to.

The command line version now also clones as well as stripping the relevant content. You use it in a batch file to keep things up to date. The GUI is to get you started.

Code: [Select]
Usages...
CODERECYCLER /?
CODERECYCLER [Folder [/s]]
CODERECYCLER [[Source.csproj] Destination.csproj]
CODERECYCLER clone [[Source.csproj] Destination Folder]
CODERECYCLER clone [[Source Folder] Destination Folder] [/s]
CODERECYCLER strip [Destination Folder [/s]]
CODERECYCLER strip [Destination.csproj]
CODERECYCLER ... /noconfirm

/?           This help text.
/noconfirm   Switch. Don't ask about overwrites etc. Use in batch jobs.

Folder   Recycles the source(s) into all CSPROJ files in the folder
         This is the destination folder that has recycled projects.
         The Destination projects need to have the source in their placeholder.
/s       Also iterates all subfolders. You just forgot this, right?
         use . for the current folder, add /s for all subfolders.

Source.csproj        optional Path to the CSPROJ with the source to be recycled.
                     if only 1 CSPROJ is specified then it is the Destination.
                     This source overrides all sources in the Destination.
Destination.csproj   Path to the existing Destination project.

clone    Clones the Source to the Destination path and strips the contents.
         Creates new project file(s) with a placeholder + Source.
         Using folders it clones all Projects to the same destination Folder.

Source Solution Root  (optional)
         The root of the solution containing the projects to recycle.
         Default is the current directory.
Destination Solution Folder
         The new Folder Name for the recycled project(s).
         If only one Folder is specifed then it is the destination folder.

strip    Creates new recycled projects from ALL existing CSPROJ in the folder.
         /s iterates all subfolders . Strips out ALL code. Adds a placeholder.
         usage: copy an existing CSPROJ. Strip it. Add a Source.
         This is like clone but doesn't copy anything.
                Update References, build settings etc. Build it. Rejoice.

It's not on Github yet, I'll start another thread and try to make more sense when it's ready.

Here's what a couple of recycled projects look like in Visual Studio.
Note the tiny arrows on the file icons - they are linked to the original.
Also note Help.cs has pending changes which show on all of its appearances.
(https://dl.dropboxusercontent.com/u/5115091/Swamppix/CodeRecyclerTeaser2.png?raw=1)

The GUI placeholder has a couple of exclusions that you'll see in the Solution Explorer if you squint (they don't have the link icon, they are local files)...
Code - XML: [Select]
  1. <!-- CodeRecycler
  2. Source: ..\CodeRecycler\CodeRecycler.csproj
  3. Exclude: app.config
  4. Exclude: *\assemblyinfo.cs
  5. Exclude: Program.cs
  6. Exclude: YesOrNo.cs
  7. -->

Coming Soon.
If you're interested.
There's a lot of lookers but only John has said anything.
Is this actually useful for anyone (apart from me)?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 21, 2015, 09:01:09 AM
I think it's a good project; keep going.

Are you using Git to it's fullest extent? -i.e. using branches and whatnot. The reason I ask is because of your `it's not on github yet'. My initial thought at that moment was that it should be in some sort of branch or another.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 09:12:56 AM
It's in a private repo at kilnhg.com

That's about 75 commits ahead if the GitHub repo but I'll scrap that & start clean.

The public repo is a condensed history. Yes, separate branch.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 21, 2015, 09:59:22 AM
*facepalm* ...okay, I'll try to just keep my mouth shut (*COUGH: GET ORGANIZED!!!!*).

A Fog creek user? I was kind of disappointed when I heard about them and I found out they were paid only. Do you like it?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 02:59:26 PM
*facepalm* ...okay, I'll try to just keep my mouth shut (*COUGH: GET ORGANIZED!!!!*).

A Fog creek user? I was kind of disappointed when I heard about them and I found out they were paid only. Do you like it?

No, please, keep up the conversation- you have been a great help. You got me organised!

I don't use the Fogbugz part of the deal much these days, mostly because Trello is so good but it has definitely evolved since I started using it.. Btw it's free for 1-2 users. Follow the link in my post at http://www.theswamp.org/index.php?topic=32381.msg486114#msg486114 and find the startups link on their pricing page. That post may also have other info you may find interesting.

I still prefer Kiln, mostly because you can organise things into projects, something the I've only seen in Gitlab and, recently, Bitbucket. Both of them are free for private repos.

I actually use Kiln & Bitbucket, I push to both so I have a mirror. Gitlab looks good, I haven't used it much and it's not established enough to be my primary, yet.

Try Smartgit, if I can convince you into trying a GUI.

RIghtyo, off to work.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 21, 2015, 03:28:58 PM
Nah, I don't need another code host. Nor do I need to slow myself down by using a GUI. I evaluated smartgit when I was recommending a GUI for user who was looking to get into using VC (nice but git was intended to be used from the command line and any GUI seems like a kludge--besides, you know Git has a built in GUI right?).

My primary hosts are Bitbucket and Visual Studio Online, I have a github account but I really don't like github that much. Lately my primary has been VSO because I can create Backlogs, Stories, and all that agile stuff right there and even have VSO build my project for me. Very, very nice.

Are you using you .git/config file for pushing/pulling branches to each host or are you doing things some weird way you invented on the fly?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 06:08:56 PM
Quote from: John Kaul (Se7en) on Today at 05:28:58 am
Quote
Nah, I don't need another code host. Nor do I need to slow myself down by using a GUI. I evaluated smartgit when I was recommending a GUI for user who was looking to get into using VC (nice but git was intended to be used from the command line and any GUI seems like a kludge--besides, you know Git has a built in GUI right?).

The thing I most like about the GUI (SmartGit, TortoiseHg & SourceTree) is the way they manage a list of repos and can show you the status of all of them at once, or at least easily find the one you're looking for. I work on a few different PCs that I need to keep in sync but I'm generally the only one editing the code. I do most of my commits in Visual Studio's git palette. Visual Studio's diff is nice and convenient too. I also like Smartgit's diff. The GUIs that come with Git are a bit fugly, no improvement on the command line and they don't do Hg which I still use a lot.

Quote from: John Kaul (Se7en) on Today at 05:28:58 am
Quote
Lately my primary has been VSO because I can create Backlogs, Stories, and all that agile stuff right there and even have VSO build my project for me. Very, very nice.
Yes, VSO has come a long way - I haven't used it much because I work alone so I can get away with my dodgy Trello workflow. It would be my 1st choice if I had the reasons you just mentioned. When I regain momentum with my bigger projects I will reconsider moving them to VSO.

Quote from: John Kaul (Se7en) on Today at 05:28:58 am
Quote
Are you using you .git/config file for pushing/pulling branches to each host or are you doing things some weird way you invented on the fly?
The latter, I'm not that clever with Git - yet. I'm pleading "too old and too busy with small children" on that one. I keep a separate folder on disk for the public repo and sync it with my working copy using Free File Sync, then push it to Github with a saner history - my private commit message list reads like a Tourette's transcript. I use GitHub flow branching on big projects but on this one it's just one branch.

I also use Free File Sync to manage drawings between local working copies and client networks while keeping old versions in a sane, discoverable manner. See http://stackoverflow.com/a/33138827/492 for how I do that.
</offtopic>



< .. >  I keep a separate folder on disk for the public repo and sync it with my working copy using Free File Sync (http://www.freefilesync.org/), then push it to Github with a saner history 
< .. >


That looks like an interesting App; thanks Ewen.


added;
Oh bollocks .. Sorry CADbloke, I stuffed up. I modified your post instead of quoting it.  :oops:
John, is there a way to restore Ewens post ??


added : revisionist history ... the names have been changed to implicate the guilty
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 21, 2015, 07:30:35 PM
I don't think so. I think the post is gone for good. Sorry.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: Kerry on October 21, 2015, 07:45:39 PM

there may be a requirement for flagellation  ...
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 08:10:37 PM
@Kerry - here's your homework from chrome://cache/ - it's the cached html of my post.

Here's a good tool for viewing the cache: http://www.sensefulsolutions.com/2012/01/viewing-chrome-cache-easy-way.html
from http://superuser.com/questions/411506/how-to-view-chromes-cached-web-page
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: Kerry on October 21, 2015, 08:26:46 PM

Most excellent !!

Thanks Ewen.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 21, 2015, 08:52:19 PM
I know your orig post is in limbo right now but it sounds like you're doing some hoop jumping.  I want to try and set up an example to play with (I don't really understand why the seperate program is needed so I'd like to toy with concepts).
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 21, 2015, 09:14:58 PM
I know your orig post is in limbo right now but it sounds like you're doing some hoop jumping.  I want to try and set up an example to play with (I don't really understand why the seperate program is needed so I'd like to toy with concepts).
The post is back.
The program just automates the task of keeping projects in sync. If your original project never changed (no additions, deletions, renames) then the project with the links would never need changing. Good luck with that. I'm just automating a very boring, error-prone  task - set and forget. Boring stuff like ... if you add code to the destination project and Visual Studio drops it in the Recycle zone then I'll move it out of the zone on the next recycle so it doesn't mysteriously vanish when the Recycle is refreshed.

My original want was to build my Find - Replace tool for more than just AutoCAD - BRicsCAD's replace tool is ... hmmm. The code wouldn't need to be much different to build it for BricsCAD (mostly UI stuff) so I wanted a way for the original code to work. I've tried a few different ways over the years and they are all nightmare-complicated and very brittle. This one keeps it all in Visual Studio so I can see what is going on. It's not a way to build the same code different ways, it's a way to use the same code in different places. A shared DLL wouldn't work because AutoCAD & Teigha are like cats & dogs. So are AutoCAD v2010 and v2016.

The most most recent rendition of the code is attached. This has the GUI project in it. It is nearly ready for daylight - it certainly won't harm any Source projects, it NEVER writes to those.

Have a look at the csproj files in to to see what is going on. Diff the CodeRecycler.csproj & CodeRecyclerGui.csproj files for a good example of two projects that share the same code and a completely different UI. Well, I think it's a good example of that concept, it may not be a good example of coding standards.  :idiot2:

Note that if you run them from their bin folders their log files will be separate, the log is local to the .EXE.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 22, 2015, 03:41:20 PM
I downloaded the project and got as far as opening it. Sorry, haven't found time to do much anything else.

I'm not sure about what you mean by the 'Recycle zone' (remember I have almost zero knowledge of Visual Studio). I also haven't had time to set up a repo to play with concepts but I do have some notes I think you might find of use.
Note (I typically do/have):
1. "good branch mgmt" practices.
2. Make use of my .git/config file.
3. Maintain a .gitignore file.

Here are my notes I think you can glean something from (hope you find something useful in them). These notes are not complete/pretty/etc. because they are my personal notes -ie I didn't write them for [you], I wrote them for me.
Quote
Deploying content to a network server can be handled several different ways -i.e. using rsync, using scripts, or using git. Each have good and bad points.

== Scenario 1: Using Rsync ==

RSync is an obvious choice because it has been in place and used in Unix for many years. RSync offers small and fast transfers and can be easily setup and maintained. However, when working on a project there is often items that are not completed or in the process of being moved/deleted/renamed that may or should not be transfered to the network.

=== Good ===
1. Very effecient program.

=== Bad ===
1. CLI tools are unpopular with Windows users.
2. We are already using Git, we should be able to use it to do this maintenance instead of relying on third party tools.


== Scenario 2: Using GIT HOOKS ==

This senario uses git hooks to do some copying/syncing for us. This solution is extremely easy to use and maintain.

=== Good ===
1. All maintenance is automatic.
2. Extremely quick.
3. Almost zero overhead for setup.

=== Bad ===
1.

First thing we need aside from our local repository is a bare remote
repository.

        == on the network ==
        1. Make a directory and establish a bare repository.

        `mkdir <network>/remote_repository.git`
        `cd <network>/remote_repository.git`
        `git init --bare`
       
        2. Now we need to set up the HOOK. We will be using the POST-RECEIVE
        hook.
       
        `cat > hooks/post-receive`
        `#!/bin/sh`
        `GIT_WORK_TREE="<network>/<end-users-library> git checkout -f`
       
        3. We need to make the post-receive script executable.
       
        `chmod +x hooks/post-receive`
       
        == in local ==
        1. We need to set up a remote location for our repository to
        push to and assign an alias for it (we'll use "production" as
        our alias).
       
        `git remote add production <network>/remote_repository.git`

        2. Create the branch on the remote (we will be using the
        "master" branch) and push to it.

        `git push production +master:refs/heads/master`

Using our new setup is very easy.

`git push production`

Now our <end-users-library> should contain a copy of our content.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 22, 2015, 05:36:40 PM
I downloaded the project and got as far as opening it. Sorry, haven't found time to do much anything else.

I'm not sure about what you mean by the 'Recycle zone' (remember I have almost zero knowledge of Visual Studio). I also haven't had time to set up a repo to play with concepts but I do have some notes I think you might find of use.
Note (I typically do/have):
1. "good branch mgmt" practices.
2. Make use of my .git/config file.
3. Maintain a .gitignore file.

Here are my notes I think you can glean something from (hope you find something useful in them). These notes are not complete/pretty/etc. because they are my personal notes -ie I didn't write them for [you], I wrote them for me.

Thanks for those notes - they make sense to me, I'll have a look at them when I have a quiet moment. That certainly looks like a more robust, set-and-forget method than syncing folders when I think of it. I imagine I would do the occasional merge commit to the branch I sync with the public Github repo so I don't clutter that history with my private commit messages. Pulling back from Github I'd merge or rebase (depends on the changes in both) into my dev branch.

The "Recycle zone" isn't a Visual Studio thing, it is the section my app adds to the Visual Studio project file. That's a good point, I really need to clarify that, well, everything. I haven't fixed the wiki yet.

If you to a text diff between the CodeRecycler.csproj & CodeRecyclerGui.csproj files you will see what my app does. The clone process copies the source project, strips all the "<... Include = ...>" XML Elements and replaces them with links to the original. A VS project file is basically an MSBuild project with extra stuff for Visual Studio. If you look at the XML comment at the first difference you will see the instructions for where to get the source and what to leave out.

Here's a screengrab of the diff of the "Recycle Zone"...
(https://dl.dropboxusercontent.com/u/5115091/SwampPix/CodeRecyclerGUIdiff.png?raw=1)
It has just occurred to me that it needs an "Include" parameter too. There's a job for today.

...update...attached a newer version that also does "Include:" - if you omit that it will include everything. If you run the command-line EXE with no parameters or "/?" and check out the log file (in the same folder as the EXE) there will be some instructions at the end of it.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 23, 2015, 09:41:23 AM
I'll wait until you get the code hosted before I check it out more.

I really do hope you can grok something from those notes. I know they aren't the best (I really don't have a lot of time on my hands lately) so I'll take a quick moment to try and direct you a little better down a rabbit hole. Pay close attention to the final steps in the above notes.
-i.e.
Code: [Select]
git remote add production <network>/remote_repository.git
git push production +master:refs/heads/master

What I mean by that is, in your .git/config file you can set up something like:
Code: [Select]
[remote "bb"]
url = https://JohnKaul@bitbucket.org/JohnKaul/...
fetch = +refs/heads/*:refs/remotes/bb/*
[branch "bbmaster"]
remote = bb
merge = refs/heads/master
[remote "vs"]
url = https://jkaul.visualstudio.com/DefaultCollection/_git/...
fetch = +refs/heads/*:refs/remotes/vs/*
[branch "vsmaster"]
remote = vs
merge = refs/heads/master

This would be a lot better then the kludge your currently employing.


Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 23, 2015, 10:57:45 AM
I would also like to make another suggestion to you about your commit log. A few years back I read a proposal to make a standard commit message format and my logs are a lot cleaner and easier to understand because I attempted to adopt that recommendation. The recommendation was simply:

<Subject>:
<Blank line>
<Details>

So a typical commit for me would be (taken from a repo of mine):
Code: [Select]
* 3aa39fd : (8 days ago) ~ John Kaul  (HEAD, origin/work, work)
|    .gitignore:
|
|    Added the tags file to the ignore list.
|
* 4020fff : (8 days ago) ~ John Kaul
|    (Multiple files) buffer.cpp, buffer.h:
|
|    1. I have spent some time cleaning these files; I moved all definition code
|       to the .cpp file (from the .h).
|    2. Made the headers a little more consitant with eachother; added some
|       ARGS and RETURN comments to the function headers.
|    3. Refomatted the code to be a little more consitant; used proper
|       indentents and etc.
...

You can even make a template for this. Here is a template I am currently working on for myself.
Code: [Select]
#  Please enter the commit message for your changes. Lines starting
#  with '#' will be ignored, and an empty message aborts the commit.
#
#  You MUST wrap all lines at 72 characters.
#
#
# ==[ Subject/Filename: One line ONLY short meaningful description ]===|

# ==[ Blank: Follow the Subject with a blank line, do NOT remove ]=====|

# ==[ Details: Describe what changed and explain why it changed]=======|


# ==[ Fields: Uncomment and edit where applicable ]====================|
#
# --[ Close bug in project as fixed ]----------------------------------|
#BUG: <bug number>
#FIXED-IN: <optional release version>
#
# --[ Add to release changelog optionally close wish in project ]------|
#FEATURE: <optional bug number>
#FIXED-IN: <optional release version>
#
# --[ Copy commit message to a bug or wish in project ]----------------|
#CCBUG: <bug number>
#
# --[ Copy commit message to an email address ]------------------------|
#CCMAIL: <email>
#
# --[ Notify documentation team of user visible changes ]--------------|
#GUI:
#
# --[ Notify Commit Digest team of something interesting ]-------------|
#DIGEST:
#
# --[ Mark commit as silent for commit filter filtering. ]-------------|
#   [ Use sparingly and only for uninteresting and       ]
#   [ uncontroversial commits.                           ]
#GIT_SILENT
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 25, 2015, 07:07:55 PM
I really do hope you can grok something from those notes....
This would be a lot better then the kludge you're currently employing.
YES, yes it is better. I'll set that up. Thanks. I understand your notes, especially after the follow-up there, thanks -  I just need to find time to implement them.

Thanks for the notes on the commit messages. I  kinda do the same thing, kinda don't. I like to link to work items, Trello cards etc too. I guess I write my commits just for myself so I need to reconsider that position. I tend to commit often, my Find-Replace project has 938 commits and it hasn't even shipped (https://unicornfree.com/just-fucking-ship/) yet.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 26, 2015, 08:49:08 AM
I went with "Code Linker". You should have seen that renaming commit (https://github.com/CADbloke/CodeLinker/commit/c6ca0b090318caab0a7c6b0997bd00e5f9171263).  :tickedoff: . I should add more SEOness about it being for Visual Studio but it's late and I'm tired.

Published to Github (https://github.com/CADbloke/CodeLinker).
...for those of you scrolling through looking for a link to the repo...

The Wiki (https://github.com/CADbloke/CodeLinker/wiki) is still a work in progress but it has some info about the GUI app and other things.

Please let me know what doesn't make sense. It's late, I'm tired but I just want to get it out to you. I will revisit it soon and edit my drivel.

As per John's suggestions and notes, publishing on a separate branch in Git is working well for me ... so far...I used these 2x commands.

Code - Bash: [Select]
  1. git checkout --orphan github
  2. git push github github:master
Line 1 creates the empty branch (http://stackoverflow.com/a/4288660/492). There should be a line 1-1/2 but I did the commit to that branch in a GUI.
Line 2 establishes the link between the local branch and the remote branch (http://stackoverflow.com/a/1519032/492) on Github.

I ended up with this in .git\config
Code - Text: [Select]
  1. [remote "origin"]
  2.         url = https://cadbloke.kilnhg.com....git
  3.         fetch = +refs/heads/*:refs/remotes/origin/*
  4. [branch "master"]
  5.         remote = origin
  6.         merge = refs/heads/master
  7.         rebase = true
  8. [branch]
  9.         autosetuprebase = always
  10. [remote "github"]
  11.         url = https://github.com/CADbloke/CodeLinker.git
  12.         fetch = +refs/heads/*:refs/remotes/github/*
  13. [branch "github"]
  14.         remote = github
  15.         merge = refs/heads/github
  16.         rebase = true

...EDIT... This got tedious after setting it up on the 4th PC - the Github history is now the same as my private repo - warts and all.

Some notable small wins along the way
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: owenwengerd on October 29, 2015, 10:51:02 AM
Found on MSDN for what it's worth: Project Linker: Synchronization Tool (https://msdn.microsoft.com/en-us/library/ff921108(v=pandp.20).aspx)
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 29, 2015, 12:30:31 PM
Found on MSDN for what it's worth: Project Linker: Synchronization Tool (https://msdn.microsoft.com/en-us/library/ff921108(v=pandp.20).aspx)
lol

Here is a link to the download (I think). I had to search the web for this (because the link Owen provided didn't say how to get the actual product :? ) so I thought I'd share (of course, this could be a known place to find VS plugins so, in that case, never mind me).
https://visualstudiogallery.msdn.microsoft.com/273dbf44-55a1-4ac6-a1f3-0b9741587b9a

Also I noticed the following conversation in the Q/A portion of the app:
Quote
andreas.laendle
Are there any plans to support VS 2013? I would really like to have this tool available in the new IDE ;-) Thanks for all your work.

Written October 23, 2013
RobGibbens
This extension will install in VS2013 with some manual editing.

1. Download vsix
2. Change extension from vsix to zip
3. Unzip the file
4. Open "extension.vsixmanifest" in text editor
5. Change the line
    <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="11.0" />
    to
    <InstallationTarget Id="Microsoft.VisualStudio.Pro" Version="12.0" />
6. Zip all files back up
7. Rename to .vsix
8. Double click file

And here is something to consider for your tool CadBloke if you keep at yours:
Quote
An option to synchronize projects?
4 Posts | Last post June 11, 2013

Written March 07, 2013
Miha Markic
AFAIK there isn't an option to re-link the projects if they get unsynchronized - i.e. if I edit only the source project without the target.

It would be really useful to have such an option.

Written May 13, 2013
Nikola Malovic
Maybe Project Linker source code could inspire someone to add that option :) http://compositewpf.codeplex.com/releases/view/46111 (e)

Written May 17, 2013
Jonkers
The code of this version can be found at: https://projectlinker2012.codeplex.com.

I currently haven't got the time. So please go ahead and drop me a line if you want to make changes.
:)

Written June 11, 2013
Jonkers
Published the project at https://projectlinker2012.codeplex.com
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 29, 2015, 06:28:24 PM
Found on MSDN for what it's worth: Project Linker: Synchronization Tool (https://msdn.microsoft.com/en-us/library/ff921108(v=pandp.20).aspx)
...
And here is something to consider for your tool CadBloke if you keep at yours:
Quote
An option to synchronize projects?
4 Posts | Last post June 11, 2013

Written March 07, 2013
Miha Markic
AFAIK there isn't an option to re-link the projects if they get unsynchronized - i.e. if I edit only the source project without the target.
...

Written June 11, 2013
Jonkers
Published the project at https://projectlinker2012.codeplex.com
[/quote]
My project keeps the targets refreshed already (https://github.com/CADbloke/CodeLinker/wiki/Command-Line#examples). If you use a post-build event (https://github.com/CADbloke/CodeLinker/wiki/Visual-Studio-Pre-or-Post-Build-Event) then it happens every time you build the source. The target doesn't need to be loaded anywhere, it just need to be accessible to the file system.

I'll have a look at that repo at CodePlex when I get the chance. I had a quick look at the MSDN page. I think checking for duplicates is a good idea, I'll get on to that ... sometime.

If you haven't pulled from the Github repo (https://github.com/CADbloke/CodeLinker) in the last couple of days then you may notice it changed. I got sick of fiddling with sanitised histories to I reset the Github repo to be the same as my work in progress. Same code, more rants. I'm leaving it there in that form. I have also updated the Wiki.

I didn't want anything as intrusive as VS extension or something that has to be installed and/or live in the PATH. I wanted Code Linker to be as portable as the source code - it will work for anyone who clones the repo as long as CodeLinker.exe is in the repo. It has no dependencies, it doesn't even depend on Visual Studio.

As it stands I am using this already and it is working well for me. It actually builds itself, 3 of the 4 projects in that repo are built from the original command line project.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on October 30, 2015, 10:19:14 AM
Found on MSDN for what it's worth: Project Linker: Synchronization Tool (https://msdn.microsoft.com/en-us/library/ff921108(v=pandp.20).aspx)
...
And here is something to consider for your tool CadBloke if you keep at yours:
Quote
An option to synchronize projects?
4 Posts | Last post June 11, 2013

Written March 07, 2013
Miha Markic
AFAIK there isn't an option to re-link the projects if they get unsynchronized - i.e. if I edit only the source project without the target.
...

Written June 11, 2013
Jonkers
Published the project at https://projectlinker2012.codeplex.com

My project keeps the targets refreshed already (https://github.com/CADbloke/CodeLinker/wiki/Command-Line#examples). If you use a post-build event (https://github.com/CADbloke/CodeLinker/wiki/Visual-Studio-Pre-or-Post-Build-Event) then it happens every time you build the source. The target doesn't need to be loaded anywhere, it just need to be accessible to the file system.

I'll have a look at that repo at CodePlex when I get the chance. I had a quick look at the MSDN page. I think checking for duplicates is a good idea, I'll get on to that ... sometime.

If you haven't pulled from the Github repo (https://github.com/CADbloke/CodeLinker) in the last couple of days then you may notice it changed. I got sick of fiddling with sanitised histories to I reset the Github repo to be the same as my work in progress. Same code, more rants. I'm leaving it there in that form. I have also updated the Wiki.

I didn't want anything as intrusive as VS extension or something that has to be installed and/or live in the PATH. I wanted Code Linker to be as portable as the source code - it will work for anyone who clones the repo as long as CodeLinker.exe is in the repo. It has no dependencies, it doesn't even depend on Visual Studio.

As it stands I am using this already and it is working well for me. It actually builds itself, 3 of the 4 projects in that repo are built from the original command line project.

That's the way your repo should be! You are writing this so you (or someone else) can come back and figure out where bug 'x' was introduced and "why" you choose to do something. ...a sterile history does anyone very little good at all; Use tags and releases. Don't worry about your history as much as you do. This is a process not a leap.

I did clone your project and started looking at it. One suggestion is to start cleaning your code a little (and where are the comments!!). Your syntax rules are all over the place; pick a std syntax rule and stick to it.
For example:

Bad:

Code - C#: [Select]
  1. if (test) code

or

Code - C#: [Select]
  1. if(test)
  2.     code
  3. // These look nice but are hard to read later (when looking for bugs you are scanning the code and
  4. // this style gets in the way often.


Good:
Code - C#: [Select]
  1. if ( test ) {
  2.     code
  3. }
  4. // My rules:
  5. // 1. Space before the '('.
  6. // 2. Space before <TEST>.
  7. // 3. Open '{' on same line.
  8.  
  9. if ( test ) {
  10.     code
  11. } else {
  12.     more code
  13. }
  14. // Else on same line as '}'

or

Code - C#: [Select]
  1. if ( test ) {
  2.     code
  3. }
  4. else {
  5.     more code
  6. }
  7. // Else on new line.

My rules are evolving over time but I normaly put the '{' on the same line of everything (functions, statements, etc) except CLASSES and NAMESPACES.

NOTE:
Code - C#: [Select]
  1. internal string SOMETHING { get; ]
is okay.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on October 31, 2015, 04:37:39 AM
If you haven't pulled from the Github repo (https://github.com/CADbloke/CodeLinker) in the last couple of days then you may notice it changed. I got sick of fiddling with sanitised histories to I reset the Github repo to be the same as my work in progress. Same code, more rants. I'm leaving it there in that form. I have also updated the Wiki.
That's the way your repo should be! You are writing this so you (or someone else) can come back and figure out where bug 'x' was introduced and "why" you choose to do something. ...a sterile history does anyone very little good at all; Use tags and releases. Don't worry about your history as much as you do. This is a process not a leap.
My own history always had all this, I'm a prolific committer and will often break commits up just to separate the bits I brokefixed. I guess I was worried about people looking at the commit log and dimissing me as insane. Meh, they were bound to figure that out sooner or later anyway.

As an aside, Git in Visual Studio 2015 Professional with CodeLens is cool, you can go straight to the relevant commits for the code you are looking at.
(https://dl.dropboxusercontent.com/u/5115091/Swamppix/VScodeLens01.png?raw=1)
...as well as navigating a list of the usages of the item too. Bummer it's not in the Community edition.

One suggestion is to start cleaning your code a little (and where are the comments!!). Your syntax rules are all over the place; pick a std syntax rule and stick to it.
...
My rules are evolving over time...
Yeah, that project was also an experiment in what formatting rules would work for me... so I tried them all. I just added at 27 inch 2560x1440 monitor to my desktop so that hasn't helped with any notion of clever use of space. I also did a lot of this at night, after a long day's work and after putting 2 kids to bed. Nevertheless, it's a mess and it needs fixing.

I also have quite colourful syntax highlighting in Visual Studio ...
(https://dl.dropboxusercontent.com/u/5115091/Swamppix/VSfrootLoops.png?raw=1)
...so visually separating types of things is easy for me. Yes, it looks like http://www.frootloops.com/ and some of you probably just threw up a little but nyah, it works for me.

Regarding braces and where to put them, there's always going to be differences in opinion and hot debate on that one, see http://programmers.stackexchange.com/questions/2715/should-curly-braces-appear-on-their-own-line#

Personally I prefer them on their own line, I like the visual separation.

I do agree that all the bits where I left off the braces need them back, lest I make another goto fail (https://nakedsecurity.sophos.com/2014/02/24/anatomy-of-a-goto-fail-apples-ssl-bug-explained-plus-an-unofficial-patch/). That's just plain wrong.

I use Resharper and it has such a complex matrix of formatting rules (https://www.jetbrains.com/resharper/help/Reference__Options__Languages__CSharp.html) that they often disagree with each other and leave you wondering why it moved things around like it did. I need to sort those rules out and ctrl-A-E-C all the things. As you said...I need to pick a std syntax rule and stick to it. Just looking at that pic I posted there are at least 3 different formats for "if". Wow, was I drinking (https://xkcd.com/323/)? Yeah, that's not right. I will definitely fix that before moving on. I'll even use the same repo this time! (not deleting the Github repo again unless I drop a credit card in it).

Comments? There's another hot (http://programmers.stackexchange.com/questions/1/comments-are-a-code-smell) debate (http://programmers.stackexchange.com/questions/254978/whats-wrong-with-comments-that-explain-complex-code).  I try to name things so obviously and verbosely that they are their own comments. *Try*. Or do you mean more XML doc comments? Please let me know where you think comments would help, I'm interested to know what I may be missing.

BTW, the Visual Studio Gallery is indeed the place to go for plugins (https://visualstudiogallery.msdn.microsoft.com/site/search?sortBy=Popularity). I use a few and yes, they slow things down a little (especially Resharper) but they help more than they hinder. If you look at the screengrab you may notice the brackets and braces are different colours - they actually use the resistor colour code (https://www.google.com/search?q=resistor+color+code&es_sm=122&tbm=isch) so I can easily tell where they match and how deep they are nested. Trivial but I find it useful.

I updated the pics at http://www.theswamp.org/index.php?topic=50202.msg553839#msg553839 and also the wiki article at https://github.com/CADbloke/CodeLinker/wiki/Illustrated-Example with new screenshots.

I have some broadcast system design work (http://www.nrl.com/video-bunker-confirmed-for-2016/tabid/10874/newsid/90491/default.aspx) that needs doing over the weekend so I won't be able to get onto this for a few days. Broadcast systems are my day job, rest assured I'm better at that than I am at this.

In the meantime I set myself a reminder (https://github.com/CADbloke/CodeLinker/issues/2)
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 02, 2015, 10:58:42 AM
...
Yeah, that project was also an experiment in what formatting rules would work for me... so I tried them all. I just added at 27 inch 2560x1440 monitor to my desktop so that hasn't helped with any notion of clever use of space. I also did a lot of this at night, after a long day's work and after putting 2 kids to bed. Nevertheless, it's a mess and it needs fixing.
...

Stick to the 80 character width (or close to it) until you nail down a style.


...
Regarding braces and where to put them, there's always going to be differences in opinion and hot debate on that one, see http://programmers.stackexchange.com/questions/2715/should-curly-braces-appear-on-their-own-line#

Personally I prefer them on their own line, I like the visual separation.

I do agree that all the bits where I left off the braces need them back, lest I make another goto fail (https://nakedsecurity.sophos.com/2014/02/24/anatomy-of-a-goto-fail-apples-ssl-bug-explained-plus-an-unofficial-patch/). That's just plain wrong.

I use Resharper and it has such a complex matrix of formatting rules (https://www.jetbrains.com/resharper/help/Reference__Options__Languages__CSharp.html) that they often disagree with each other and leave you wondering why it moved things around like it did. I need to sort those rules out and ctrl-A-E-C all the things. As you said...I need to pick a std syntax rule and stick to it. Just looking at that pic I posted there are at least 3 different formats for "if". Wow, was I drinking (https://xkcd.com/323/)? Yeah, that's not right. I will definitely fix that before moving on. I'll even use the same repo this time! (not deleting the Github repo again unless I drop a credit card in it).
...

It's fine to have an opinion and even better to read up on those but I wanted to talk about the braces thing a second because the braces on the same line offers you a feature you (or the "discussion" on SO you liked to) probably haven't addressed/thought of; Searches. To give you a solid example: if you do a search (with Visual Studio or Grep) for the string "DestinationProjLinker". You'll get this line:
" ...  \CodeLinker\DestinationProjLinker.cs(13):    internal class DestinationProjLinker"

If you had a brace on that line you'd be able to quickly discern which instance in that list is the definition code and jump there. This is, of course, a very simple example, but the principle becomes a huge time saver in a large project.

If I were you, I'd ditch reshaper until you can formulate your own opinions about what you want to look like.


...
Comments? There's another hot (http://programmers.stackexchange.com/questions/1/comments-are-a-code-smell) debate (http://programmers.stackexchange.com/questions/254978/whats-wrong-with-comments-that-explain-complex-code).  I try to name things so obviously and verbosely that they are their own comments. *Try*. Or do you mean more XML doc comments? Please let me know where you think comments would help, I'm interested to know what I may be missing.
...

I wont even click on that link; I've read that debate a 1,000 times and I don't care. I comment my code <period>. I can use simple command line tools to remove them if I had too.

The point I am trying to make is simple, try not to be so dead fast on one solution. It's great to read and find out what other people are doing but you'd be far better off reading a coding standard (Google, Mozilla, LLVM/CLANG, Chrome, etc) then to read those threads loaded with out of context opinions.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 03, 2015, 10:14:09 AM
I got a moment to start looking through your code. Now, please bear in mind that I am an absolute beginner with Csharp so I am not a resource on syntax and api stuff.

I started in "Program.cs" and I noticed that you just pass the argument list to the "App" class and parse the args from there. This isn't "terrible" (I would have, however, skipped the "app" class all together and added those functions [Parse commands, Crash, & Finish] to the main class but I digress to my point). Your argument handling is a big/nasty If-Else-If chain. So, my first code related comment will be to hopefully give you something useful. This, hopefully, is a crude argument handler which you can expand for simple arguments like you require.

Code - C#: [Select]
  1. for (int x = 0; x < args.Length; ++x) {
  2.     // Parse the argument list.
  3.     //
  4.     //      /?  :       Call help, Write log, Finsh the app.
  5.     //      /s  :       "I don't have a clue as to what this is
  6.     //                   I just put this in here for example." -7
  7.     //      ...
  8.     if (args[x] != "" && args[x].Length > 1) {
  9.         if (args[x][0] == '/' && args[x][1] == '?') { Help.Write(); Log.WriteLine("User asked for help."); Finish(); }
  10.         if (args[x][0] == '/' && args[x][1] == 's') { doSubDirectories = StringComparer.CurrentCultureIgnoreCase; }
  11.     }
  12. }
Use this to populate variables and call simple functions from. This is NOT meant to be a "main loop" of your program; it is only meant to set up.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 03, 2015, 02:37:22 PM
Looks like someone ported the GNU getopt() function to .net. Instead of using my suggestion you can also use this in your project to clean the argument processing up.

http://getopt.codeplex.com/
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on November 03, 2015, 06:43:29 PM
I started in "Program.cs" and I noticed that you just pass the argument list to the "App" class and parse the args from there. This isn't "terrible" (I would have, however, skipped the "app" class all together and added those functions [Parse commands, Crash, & Finish] to the main class but I digress to my point).
Necessary because there are two Program.Main()s, one for the command line project and one for the GUI project. Both projects use the App class.

Your argument handling is a big/nasty If-Else-If chain.
Looks like someone ported the GNU getopt() function to .net. Instead of using my suggestion you can also use this in your project to clean the argument processing up.

http://getopt.codeplex.com/
Crude, ugly but it works, it deals with all the decision paths, it doesn't have a dependency on an external library so anyone who knows what if...else does can already parse it and maintain it. It grew from just a couple of decision paths to what it is now. If I thought it was going to grow any larger then I'd refactor it into something a little more elegant like a big, nasty switch...case chain which is what Getopt wants you to do anyway. From http://getopt.codeplex.com/SourceControl/latest#Gnu.Getopt/Gnu.Getopt/Getopt.cs ...

Code - C#: [Select]
  1. /// Here is a basic example of using Getopt:
  2. /// <code>
  3. /// Getopt g = new Getopt("testprog", args, "ab:c::d");
  4. ///    
  5. ///     int c;
  6. ///     string arg;
  7. ///     while ((c = g.getopt()) != -1)
  8. ///     {
  9. ///             switch(c)
  10. ///             {
  11. ///                     case 'a':
  12. ///                     case 'd':
  13. ///                             Console.WriteLine("You picked " + (char)c );
  14. ///                             break;
  15. ///                                    
  16. ///                     case 'b':
  17. ///                     case 'c':
  18. ///                             arg = g.Optarg;
  19. ///                             Console.WriteLine("You picked " + (char)c +
  20. ///                                     " with an argument of " +
  21. ///                                     ((arg != null) ? arg : "null") );
  22. ///                             break;
  23. ///    
  24. ///                     case '?':
  25. ///                             break; // getopt() already printed an error
  26. ///    
  27. ///                     default:
  28. ///                             Console.WriteLine("getopt() returned " + c);
  29. ///                             break;
  30. ///             }
  31. ///     }
  32. /// </code>

Using a library like that just means everybody has to learn it and then I have to rewrite it to make it do what it already does without breaking it. If you'd like to do that then go right ahead. I'm ok with "ugly but it works".

Yes, I think a few comments would help. You can always run it with "/?" and read the help text in the log to see what the switches do.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 03, 2015, 06:52:48 PM
You have the dumbest excuses!  Getopt isn't some enigma...its been around since the 80's!!
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on November 03, 2015, 08:01:48 PM
I think I've had enough of the snark.
http://tirania.org/blog/archive/2010/Dec-31.html
Thank you for your help, we're done.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 03, 2015, 10:03:16 PM
Yes, I know (your last post was about as much as I could take).

I don't think any of my recommendations were out of line at all (I've asked you to conform to any *one* style of *your* choosing). And yes, I got real sick and tired of making suggestion after suggestion only to be shot down for the oddest reasons. I'm sorry you think the suggestions I made (use git instead of a manual method third party tool, remove unreliable If-Else-If chain, use or don't use braces for IF statements, etc) are bad etiquette. If you are not looking for suggestions/review/ideas I am a little confused as to what this thread is for (what is this threads purpose).

FWIW, I had some fun. Good luck.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on November 03, 2015, 10:13:02 PM
Having a (opposite of "fun") day so I'm in no mood to hear "ugly" and "dumbest" directed at something I hand-made and put out there for everyone to have. Perhaps I should avoid humans until the thickness returns to my skin.

FWIW your suggestions have a lot of value to me and to the lurkers too, I'm sure. I've learned heaps. Sorry if you think I was shooting you down, I was just trying to explain myself. The tone just got me down in the end.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on November 03, 2015, 10:26:21 PM
You used ugly not me. And what should I call it when someone says they think a method that has been ported to many languages and is used in thousands of programs is worse then a fragile if-else-if chain?

I think you should keep going but do not hesitate to refactor when you should.
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on February 22, 2016, 06:19:44 AM
I added fixed some more bugs and things if anyone is actually using this .. or wondering just how bad my code can get .. https://github.com/CADbloke/CodeLinker/commits/master and my excuses explanations at https://github.com/CADbloke/CodeLinker/issues?q=is%3Aissue+is%3Aclosed

Updated the Wiki page on using the GUI app (https://github.com/CADbloke/CodeLinker/wiki/Using-the-GUI-App) - it's mostly draggy-droppy, like all good programming.

You wouldn't believe how drunk I had to get to write Lines 111 - 117 (https://github.com/CADbloke/CodeLinker/commit/96631c750f9559914be2f845d6a989b2beb3b912?diff=unified#diff-20ac0ac15c0eeaf4eed045c29f712e52).   :whistling:
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on March 02, 2016, 09:19:33 PM
Stumbled over yet another command line parser that looks ok: https://github.com/dotnet/corefxlab/tree/master/src/System.CommandLine
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on March 04, 2016, 09:53:19 AM
Looks big and complicated. What was wrong, again, with the getopt() method I linked to or the hand-rolled--very simple--version I made for you? ...why add unnecessary complexity to a very simple task (more lines of code does not equal better)?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on March 07, 2016, 07:48:44 AM
Looks big and complicated. What was wrong, again, with the getopt() method I linked to or the hand-rolled--very simple--version I made for you? ...why add unnecessary complexity to a very simple task (more lines of code does not equal better)?
I didn't have a close look at that, just adding it for anyone following along, for future reference.

(more lines of code does not equal better)?
Totally agree, it makes it worse - more lines == more bugs.

Back to the original topic ... I tweaked a few more things (https://github.com/CADbloke/CodeLinker/commits/master) and also Resharpered the whole thing. I even set the indents to 4 instead of 2 ... which was really dumb and is not going to be much fun when I fix bigger codebases.#fail
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: John Kaul (Se7en) on March 07, 2016, 12:20:43 PM
The code is looking nicer already! And, I see you fixed some of the IF-braces issue I mentioned. Keep going.

Looks big and complicated. What was wrong, again, with the getopt() method I linked to or the hand-rolled--very simple--version I made for you? ...why add unnecessary complexity to a very simple task (more lines of code does not equal better)?
I didn't have a close look at that, just adding it for anyone following along, for future reference.

...
Well you already know my opinion on that topic (should adopt something); yes, doing so will require major refactoring to your code base. That leads me to a question for you though; in the beginning I wanted to help you (help contribute/fix/format/refactor with actual code) but you labeled my questions/points/suggestions/discussions as "poisonous" (If I understand correctly, you don't seem to want help). If this thread is only advertising (so-to-speak), I would recommend moving it to the "show your stuff" forum (I think you'll get more `followers' if people understand that minor--but important--point; a thread in this forum people tend to think of as needed/wanting help). Would you like me to move this thread to the "show your stuff" forum (let me know and I would be very happy to help)?
Title: Re: Same Code, Multiple Projects, Multiple Builds
Post by: CADbloke on March 07, 2016, 09:20:23 PM
The code is looking nicer already! And, I see you fixed some of the IF-braces issue I mentioned. Keep going.
Thanks. Some things take a while to sink in so...never give up.

It is pretty-much done to the stage where I use it in anger and it works for me. If I were to build more into it I think it needs some pretty serious refactoring to uncomplicate it and I would definitely drop in the command-line parser you have been nudging me with. For now, it works and it's not broken (much) so I'll leave it alone for a while.


in the beginning I wanted to help you (help contribute/fix/format/refactor with actual code) but you labeled my questions/points/suggestions/discussions as "poisonous" (If I understand correctly, you don't seem to want help).
Just me being a sooky princess :cry:.  I have dried my tears, I will be ok. All help is welcome, for code or otherwise.

If this thread is only advertising (so-to-speak), I would recommend moving it to the "show your stuff" forum (I think you'll get more `followers' if people understand that minor--but important--point; a thread in this forum people tend to think of as needed/wanting help). Would you like me to move this thread to the "show your stuff" forum (let me know and I would be very happy to help)?
I put it here because I thought .NET devs would be most interested in it. I'm not concerned with my popularity as such, I just wanted to explore yet another way of building the same thing for multiple upstream APIs. This should go wherever you think the most people would benefit from it. Feel free to move it if you think that's a good idea.

FWIW, it hasn't got much attention on Github, CADtest got more. Neither of them are destined to be the  Next Big Thing TM

My strike rate at picking the markets has been quite low lately, would you believe that http://www.tvcad.tv/ has more on its mailing list than http://www.cadfindreplace.com/ ? tvCAD is a $2.5k /yr app, Find-Replace a fraction of that and it has been really useful for me. Weird, this startup stuff.