FileInclude 1.0.4

dotnet add package FileInclude --version 1.0.4                
NuGet\Install-Package FileInclude -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FileInclude" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FileInclude --version 1.0.4                
#r "nuget: FileInclude, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FileInclude as a Cake Addin
#addin nuget:?package=FileInclude&version=1.0.4

// Install FileInclude as a Cake Tool
#tool nuget:?package=FileInclude&version=1.0.4                

FileInclude

A library to generate a file from template which can include placeholder sections that reference other file (i.e., file includes). The referenced files can include similar sections to reference other files.

The library was motivated by the need to reference other files in README.md file (other MD files, example code files, etc.).

The method GenerateFileFromTemplate in interface FileInclude.ITemplateProcessor recursively compiles the template file specified in parameter templateFilePath, and all the files directly or indirectly referenced by the template file into a single file and returns the file contents in output parameter generatedFileContents.

The default implementation of FileInclude.ITemplateProcessor is FileInclude.TemplateProcessor and it uses IncludedFilePlaceHolder element tag to locate the include place-holders. However the tag name can be changed by overriding the virtual property TemplateProcessor.FileIncludeTagName.

The method GenerateFileFromTemplate returns errors as a list of FileInclude.IErrorData objects that contain error details.

Also, the method checks and reports any possible circular references, to prevent infinite processing.

There is also an extension method FileInclude.TemplateProcessorExtensions.GenerateFileFromTemplateAndSave which saves the file generated from the template. The extension method checks if the generated file was modified by other applications (say manually edited) since it was auto-generated last time, to prevent data loss.

Examples

  • README.md file contents

This is README.md file that references two other md files, and am xml file.

Feature2ReadMe.md is specified using a relative path. It is expected to be in folder Feature1 within the same folder where README.md is.
<IncludedFilePlaceHolder>Feature1\Feature1ReadMe.md</IncludedFilePlaceHolder>

Feature1Example.xml is specified using a relative path in relation to folder where README.md. It is expected to be in folder Examples two levels up from folder where README.md is.
<IncludedFilePlaceHolder>..\..\Examples\Feature1Example.xml</IncludedFilePlaceHolder>

**Feature2ReadMe.md** is specified using an absolute path.
<IncludedFilePlaceHolder>c:\Feature2\Feature2ReadMe.md</IncludedFilePlaceHolder>

  • Feature1ReadMe.md file content s
This is a demo of Feature1ReadMe.md that is referenced from README.md and it references "..\Feature3\README.md".

- Summary for Feature 1
...

The contents of file "..\Feature3\README.md" will replace the placeholder below.
<IncludedFilePlaceHolder>..\Feature3\README.md</IncludedFilePlaceHolder>

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 498 4/3/2022
1.0.3 412 4/3/2022
1.0.2 423 4/2/2022
1.0.1 444 1/24/2022
1.0.0 421 1/24/2022

Changed the dependency from OROptimizer.Shared to version 2.1.1, since a small bug was fixed in OROptimizer.Shared 2.1.1 to fix incorrect relative path calculation in template files.