DIHOR.RepoFiles.Cli
0.3.0
dotnet tool install --global DIHOR.RepoFiles.Cli --version 0.3.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local DIHOR.RepoFiles.Cli --version 0.3.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DIHOR.RepoFiles.Cli&version=0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package DIHOR.RepoFiles.Cli --version 0.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DIHOR RepoFiles
DIHOR RepoFiles is a small set of NuGet packages for managing files stored in a repository using a JSON manifest.
Packages
DIHOR.RepoFiles(core)DIHOR.RepoFiles.GitHub(GitHub provider)DIHOR.RepoFiles.Configuration(IConfiguration binding)DIHOR.RepoFiles.Cli(CLI tool)
Install
dotnet add package DIHOR.RepoFiles
dotnet add package DIHOR.RepoFiles.GitHub
dotnet add package DIHOR.RepoFiles.Configuration
dotnet tool install -g DIHOR.RepoFiles.Cli
Manifest format
manifest.json is a JSON array of entries:
[
{
"filename": "data.db",
"url": "https://raw.githubusercontent.com/owner/repo/main/data.db",
"size": 123456,
"modifydate": "2024-01-01T12:00:00Z",
"metadata": "{\"minAppVersion\":\"1.2.3\",\"note\":\"Optional note\"}"
}
]
Store extra fields inside metadata as a serialized JSON string. To deserialize it without manual parsing:
public sealed class FileMetadata
{
public string? MinAppVersion { get; set; }
}
var entries = await client.GetManifestAsync<FileMetadata>();
var minVersion = entries[0].Metadata?.MinAppVersion;
Configuration (appsettings.json)
{
"RepoFiles": {
"Provider": "GitHub",
"GitHub": {
"Owner": "your-org",
"Repository": "your-repo",
"Branch": "main",
"ManifestPath": "manifest.json"
},
"GitHubPublisher": {
"Owner": "your-org",
"Repository": "your-repo",
"Branch": "main",
"Token": "github_pat_...",
"CommitterName": "RepoFiles Bot",
"CommitterEmail": "bot@your-org.com"
},
"Download": {
"TargetDirectory": "Data",
"SkipIfSameSizeAndDate": true,
"Overwrite": false
}
}
}
Usage (code)
using DIHOR.RepoFiles;
using DIHOR.RepoFiles.GitHub;
using DIHOR.RepoFiles.GitHub.Providers;
var provider = new GitHubRepositoryProvider(new GitHubRepositoryOptions
{
Owner = "your-org",
Repository = "your-repo",
Branch = "main",
ManifestPath = "manifest.json"
});
var client = new RepoClient(provider);
await client.DownloadToDirectoryAsync("data.db", "Data");
Publish (GitHub)
GitHubRepositoryPublisher uses the GitHub Contents API and requires a PAT with contents:write.
using DIHOR.RepoFiles.GitHub;
using DIHOR.RepoFiles.GitHub.Publishers;
var publisher = new GitHubRepositoryPublisher(new GitHubPublisherOptions
{
Owner = "your-org",
Repository = "your-repo",
Branch = "main",
Token = "github_pat_...",
CommitterName = "RepoFiles Bot",
CommitterEmail = "bot@your-org.com"
});
await publisher.PublishAsync("Data/manifest.json", "Distribution/manifest.json", "Update manifest");
DI registration:
services.AddRepoFilesGitHubPublisher(options =>
{
options.Owner = "your-org";
options.Repository = "your-repo";
options.Branch = "main";
options.Token = "github_pat_...";
});
CLI
dihor-repofiles list
dihor-repofiles pull data.db --dest Data
The CLI reads appsettings.json from the current directory (or pass --config).
Publish to NuGet
dotnet pack -c Release
Push the packages to NuGet.org (repeat for each project output folder):
dotnet nuget push "src/DIHOR.RepoFiles/bin/Release/*.nupkg" -k <NUGET_API_KEY> -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push "src/DIHOR.RepoFiles.GitHub/bin/Release/*.nupkg" -k <NUGET_API_KEY> -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push "src/DIHOR.RepoFiles.Configuration/bin/Release/*.nupkg" -k <NUGET_API_KEY> -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push "src/DIHOR.RepoFiles.Cli/bin/Release/*.nupkg" -k <NUGET_API_KEY> -s https://api.nuget.org/v3/index.json --skip-duplicate
Tip: store the key in an environment variable (NUGET_API_KEY) or use dotnet nuget setapikey.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.