Author Topic: Same Code, Multiple Projects, Multiple Builds  (Read 12073 times)

0 Members and 1 Guest are viewing this topic.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #30 on: October 21, 2015, 07:30:35 PM »
I don't think so. I think the post is gone for good. Sorry.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #31 on: October 21, 2015, 07:45:39 PM »

there may be a requirement for flagellation  ...
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #32 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
« Last Edit: October 21, 2015, 08:14:39 PM by CADbloke »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #33 on: October 21, 2015, 08:26:46 PM »

Most excellent !!

Thanks Ewen.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #34 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).
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #35 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.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #36 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.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #37 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"...

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.
« Last Edit: October 23, 2015, 12:45:41 AM by CADbloke »

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #38 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.


TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #39 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
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #40 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 yet.

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #41 on: October 26, 2015, 08:49:08 AM »
I went with "Code Linker". You should have seen that renaming commit:tickedoff: . I should add more SEOness about it being for Visual Studio but it's late and I'm tired.

Published to Github.
...for those of you scrolling through looking for a link to the repo...

The 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. 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 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
  • yes, it works with VB.NET
  • Yes, you can actually recycle/re-link a project you've already created with this. (I did this with the GUI 3.5 app in the project)
  • The GUI is fully draggy-droppy
« Last Edit: October 28, 2015, 07:56:14 PM by CADbloke »

owenwengerd

  • Bull Frog
  • Posts: 441
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #42 on: October 29, 2015, 10:51:02 AM »
Found on MSDN for what it's worth: Project Linker: Synchronization Tool

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #43 on: October 29, 2015, 12:30:31 PM »
Found on MSDN for what it's worth: Project Linker: Synchronization Tool
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
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

CADbloke

  • Bull Frog
  • Posts: 322
  • Crash Test Dummy
Re: Same Code, Multiple Projects, Multiple Builds
« Reply #44 on: October 29, 2015, 06:28:24 PM »
Found on MSDN for what it's worth: Project Linker: Synchronization Tool
...
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. If you use a 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 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.