FileInclude 1.0.4
dotnet add package FileInclude --version 1.0.4
NuGet\Install-Package FileInclude -Version 1.0.4
<PackageReference Include="FileInclude" Version="1.0.4" />
paket add FileInclude --version 1.0.4
#r "nuget: FileInclude, 1.0.4"
// 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 | Versions 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. |
-
net6.0
- OROptimizer.Shared (>= 2.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.