Sylvan.BuildTools.Resources 0.6.1

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
dotnet add package Sylvan.BuildTools.Resources --version 0.6.1
NuGet\Install-Package Sylvan.BuildTools.Resources -Version 0.6.1
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="Sylvan.BuildTools.Resources" Version="0.6.1">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sylvan.BuildTools.Resources --version 0.6.1
#r "nuget: Sylvan.BuildTools.Resources, 0.6.1"
#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 Sylvan.BuildTools.Resources as a Cake Addin
#addin nuget:?package=Sylvan.BuildTools.Resources&version=0.6.1

// Install Sylvan.BuildTools.Resources as a Cake Tool
#tool nuget:?package=Sylvan.BuildTools.Resources&version=0.6.1


Provides resource file support and code generation in C# projects. Referencing the Sylvan.BuildTools.Resources package will not add a rumtine dependency to your project, nor create a transitive package dependency for your nuget package. The package operates at build time and will embed resources in your output assembly, and includes compiled code files containing resource accessors.

Localized Resource .resj Files

JSON resource files provides an alternative to using resx XML resource files to define resources in C# projects.

The benefits over resx are:

  • human authorable file format (resx is human readable, but diffcult to author without documentation or tooling support)
  • generated C# code doesn't get included in project/source control (unlike designer.cs files)
  • Doesn't require modifying the .csproj (adding a single resx file will add ~12 lines to your csproj file)
  • Implemented with build-time code-gen and doesn't require Visual Studio to function. (resx files require Visual Studio design time code gen)
  • Still get Intellisense in Visual Studio for the generated code.

JSON resource files use the ".resj" file extension, and a very simple json document to specify resources. Currently supports strings and text files. Text file path should be specified relative to the resj file location. Supports creating localized satellite assemblies using the same naming convention as resx.

Example files:


  "Strings": {
    "Greeting": "Hello, Resj",
    "Farewell": "Goodbye, Resx"
  "Files": {
    "ComplexQuery": "sql/query.sql"


  "Strings": {
    "Greeting": "Hallo, Resj",
    "Farewell": "Auf Wiedersehen, Resx"

You can control the resource generation specifying a custom namespace, and the visibility of the generated class:

    <JsonResource Update="Path/To/Resource.resj">

Static String Code Generation

The static string code generation feature allows adding string constants to your project where each string constant is defined in a separate file in a folder structure. This is intended to support scenarios where you need to include long string constants that contain structured language that would be better maintained in a separate file, instead of inlining the code in a C# file. This allows text like long SQL queries, chunks of HTML or JavaScript to be edited in a file with appropriate syntax highlighting, then accessed from C# code as if it were defined as a native string constant.

Static resources are added to a project by defining a StaticResourceFolder item in the .csproj file, which names a folder that contains static resource files.

		<StaticResourceFolder Include="Sql"/>

If the Sql folder contains a file named select_user_data.sql it would generate code roughly equivalent to the following:

namespace ProjectRootNamespace {
    class Sql {
        public static readonly string SelectUserData = "...";

The generated code is compiled into the project assembly, but is not included in the project source code. The generated types/members will still be visible in intellisense in Visual Studio.

Release Notes:


  • Adds PreProcess capability to StaticResourceFolder.
  • Improves error reporting for some malformed JSON scenarios.


  • Adds support for generating static code from a folder holding static resources (non-localizable).


  • Mark package as DevelopmentDependency so it doesn't become a transitive dependency for consuming packages.


  • Project/package renamed to avoid name collision with technology from mega-corp.


  • Adds code comments to generated code, allowing projects that use WarningsAsErrors and DocumentationFile to compile without error.
  • Big thanks to @teddybeermaniac for his contribution here.

Running Sylvan.BuildTools.Resources.Tests on Unix

If you'd like to develop Sylvan.BuildTools.Resources under Mono, and encounter issues with reference assemblies not being found while running tests, you might need to run something similar beforehand (source1, source2):

export FrameworkPathOverride=/lib/mono/4.6-api
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Sylvan.BuildTools.Resources:

Repository Stars
The fastest .NET library for reading Excel data files.
Version Downloads Last updated
0.6.1 1,263 1/23/2023
0.6.1-b0001 370 1/22/2023
0.6.0 1,431 1/20/2022
0.5.1 243 1/10/2022
0.5.0 555 1/27/2021