DIHOR.RepoFiles.GitHub
0.3.0
dotnet add package DIHOR.RepoFiles.GitHub --version 0.3.0
NuGet\Install-Package DIHOR.RepoFiles.GitHub -Version 0.3.0
<PackageReference Include="DIHOR.RepoFiles.GitHub" Version="0.3.0" />
<PackageVersion Include="DIHOR.RepoFiles.GitHub" Version="0.3.0" />
<PackageReference Include="DIHOR.RepoFiles.GitHub" />
paket add DIHOR.RepoFiles.GitHub --version 0.3.0
#r "nuget: DIHOR.RepoFiles.GitHub, 0.3.0"
#:package DIHOR.RepoFiles.GitHub@0.3.0
#addin nuget:?package=DIHOR.RepoFiles.GitHub&version=0.3.0
#tool nuget:?package=DIHOR.RepoFiles.GitHub&version=0.3.0
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 | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- DIHOR.RepoFiles (>= 0.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.