Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I have this codebase called Grimoire that contains most of the things I've found worth doing twice, well.

Parsers, FA state generators, Network stuff, even MIDI processing.

Then when i want to use it, I include the relevant code.

When it started, it was just snippets almost.

Then as my library matured, I started building elaborate frameworks and it got overwhelming to keep self-contained code to its own source file.

See my "tried" portion and tell me if there's a better way to manage complex source dependencies.

Normally I'd use DLLs for everything like everyone else does but i like to build standalone exes because they're easier to distribute and install. they're usually self installing too.

What I have tried:

To remedy the issue and keep sourcecode into easy to include format I built a way to generate merged and 'minified' "bricks" of source code which I then "symbolic link" into my project from the core repository. That way I don't have to add half a dozen files for bit of functionality, and I don't have to keep track of all those cross dependencies in my head. They're all in a single "brick" generated using a VS custom tool from a set of input files. This makes it so i only need to reference one file in my destination project, and that includes all of my necessary library code.


I feel I missed whatever better way came along in the past decade or so that i've been out of development professionally.

________________________ example part of "code brick" ________________

// Dependencies for Cauldron
#define COLLECTIONUTILITY_CS
#define STRINGUTILITY_CS
#define STRINGUTILITY_PARSING_CS
#define PARSECONTEXTEXPRESSIONS_REGEX_CS
#define STRINGUTILITY_RANGES_CS
#define STRINGUTILITY_PARSING_CSHARP_CS
#define STRINGUTILITY_PARSING_T4_CS
#define FAUTILITY_CS
#define FAUTILITY_CODEGENERATOR_CS
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
#if !GRIMOIRELIB
namespace Grimoire{using System;using System.Collections;using System.Collections.Generic;using IEnumerable
=System.Collections.IEnumerable;using IEnumerator=System.Collections.IEnumerator;
#if GRIMOIRELIB
public
#else
internal
#endif
static partial class CollectionUtility{
#region CollectionAdapter
internal sealed class CollectionAdapter:ICollection{internal CollectionAdapter(IEnumerable inner){_inner
=inner;}readonly IEnumerable _inner;public int Count{get{return Count(_inner);}}public bool IsSynchronized
{get{return false;}}object ICollection.SyncRoot{get{return this;}}public void CopyTo(Array array,int
index){CollectionUtility.CopyTo(_inner,array,index);}public IEnumerator GetEnumerator(){return _inner.GetEnumerator();
}}internal sealed class CollectionAdapter<t>:ICollection<t>{internal CollectionAdapter(IEnumerable<t>
inner){_inner=inner;}readonly IEnumerable<t>_inner;public int Count{get{return Count(_inner);}}public
bool IsReadOnly{get{return true;}}public void CopyTo(T[]array,int index){CollectionUtility.CopyTo(_inner,
array,index);}public IEnumerator<t>GetEnumerator(){return _inner.GetEnumerator();}void ICollection<t>.Add(T
item){throw new NotSupportedException("The collection is read-only.");}bool ICollection<t>.Remove(T
item){throw new NotSupportedException("The collection is read-only.");}void ICollection<t>.Clear(){
throw new NotSupportedException("The collection is read-only.");}public bool Contains(T item){return
Contains<t>(_inner,item);}IEnumerator IEnumerable.GetEnumerator(){return _inner.GetEnumerator();}}
#endregion CollectionAdapter
Posted
Updated 19-Mar-19 21:54pm

1 solution

You can also use a utility like ILmerge, or even better Fody Costura to merge all dll's into one exe. This won't work for complicated projects though.
GitHub - Fody/Costura: Embed references as resources[^]
GitHub - dotnet/ILMerge: ILMerge is a static linker for .NET Assemblies.[^]
Merging .NET assemblies using ILMerge[^]
 
Share this answer
 
v2
Comments
honey the codewitch 20-Mar-19 4:19am    
Thanks. The last time I tried using ILMerge for this it wound up breaking for some builds and never could figure out why. That was years ago when it was still posted over at MSR or someplace and experimental. I forgot about it until you just mentioned it.

I'll certainly revisit that again.

I want to avoid embedding references as resources (something I've considered) because of the additional concerns it raises in terms of .NET security restrictions and non-fixed disk space requirements - usually doesn't matter but when it does it breaks bad.

I'm going to hold off accepting just to see what other ideas people have, if any.

Your answer regarding ILMerge is potentially a good solution, but I need to look into it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900