AlRevolver.GoogleSheets
1.0.0
See the version list below for details.
dotnet add package AlRevolver.GoogleSheets --version 1.0.0
NuGet\Install-Package AlRevolver.GoogleSheets -Version 1.0.0
<PackageReference Include="AlRevolver.GoogleSheets" Version="1.0.0" />
<PackageVersion Include="AlRevolver.GoogleSheets" Version="1.0.0" />
<PackageReference Include="AlRevolver.GoogleSheets" />
paket add AlRevolver.GoogleSheets --version 1.0.0
#r "nuget: AlRevolver.GoogleSheets, 1.0.0"
#:package AlRevolver.GoogleSheets@1.0.0
#addin nuget:?package=AlRevolver.GoogleSheets&version=1.0.0
#tool nuget:?package=AlRevolver.GoogleSheets&version=1.0.0
AlRevolver.GoogleSheets
AlRevolver.GoogleSheets is an MSBuild task that reads Google Sheets through the Google Sheets API and generates project files during build.
It can generate:
tables.jsonfrom regular sheets.- Neutral and culture
.resxfiles from sheets ending with.resx. - Public
*.Designer.csresource classes for generated.resxfiles.
The package imports its MSBuild target automatically when it is referenced directly by a project.
Install
dotnet add package AlRevolver.GoogleSheets
Google Setup
- Create a Google Cloud service account.
- Enable the Google Sheets API for the project.
- Download the service account JSON credentials file.
- Open the JSON and copy the
client_emailvalue. - Share the Google Sheet with that
client_email.
Do not commit the credentials file. Keep it local or provide it through CI secrets.
Example .gitignore entry:
/credentials.json
/.secrets/
Minimal Project Setup
Add these properties to the consuming .csproj:
<PropertyGroup>
<AlRevolverGoogleSheetsEnabled>true</AlRevolverGoogleSheetsEnabled>
<AlRevolverGoogleSheetsSpreadsheetId>YOUR_SPREADSHEET_ID</AlRevolverGoogleSheetsSpreadsheetId>
<AlRevolverGoogleSheetsCredentialsFile>$(MSBuildProjectDirectory)\credentials.json</AlRevolverGoogleSheetsCredentialsFile>
</PropertyGroup>
SpreadsheetId is the value in a Google Sheets URL between /d/ and /edit.
For example, this URL:
https://docs.google.com/spreadsheets/d/1ZxCvBnMqWeRtYuIoPaSdFgHjKl123456789ABCDEf-vdmAPckw/edit
uses this id:
1ZxCvBnMqWeRtYuIoPaSdFgHjKl123456789ABCDEf-vdmAPckw
Build
dotnet build
Or pass the required values from the command line:
dotnet build `
/p:AlRevolverGoogleSheetsEnabled=true `
/p:AlRevolverGoogleSheetsSpreadsheetId=YOUR_SPREADSHEET_ID `
/p:AlRevolverGoogleSheetsCredentialsFile=C:\path\to\credentials.json
If AlRevolverGoogleSheetsCredentialsFile is not set, the task checks these environment variables:
ALREVOLVER_GOOGLE_SHEETS_CREDENTIALS_FILEGOOGLE_APPLICATION_CREDENTIALS
Generated Files
By default the task writes into:
Generated/GoogleSheets
Generated files are added to the current build:
tables.jsonis added asContentwithCopyToOutputDirectory=PreserveNewest..resxfiles are added asEmbeddedResource.*.Designer.csfiles are added asCompile.
The task writes files only when content changes, so unchanged sheets do not touch timestamps.
Regular Sheet Format
Each sheet name becomes a JSON property in tables.json.
Example sheet named Units:
| Name | Hp | Attack | Type | |
|---|---|---|---|---|
| Archer | 100 | 20 | 0 | Range |
| Cavale | 100 | 20 | 1 | Cavalery |
With the default ignored column D, this generates:
{
"Units": [
{
"Name": "Archer",
"Hp": 100,
"Attack": 20,
"Type": "Range"
},
{
"Name": "Cavale",
"Hp": 100,
"Attack": 20,
"Type": "Cavalery"
}
]
}
Rules:
- Header row defaults to row
1. - Empty header cells are ignored.
- Ignored columns do not appear in JSON.
- Empty data rows are skipped.
- Values are parsed as
bool, integer, decimal, or string.
ResX Sheet Format
Any sheet whose name ends with .resx generates .resx files and a public designer class.
Example sheet named Units.resx:
| Name | Neutral Value | Neutral Comment | ru-ru |
|---|---|---|---|
| Archer | Archer | Unit name | Лучник |
| Cavalery | Cavalery | Unit name | Кавалерия |
Generated files:
Generated/GoogleSheets/Units.resx
Generated/GoogleSheets/Units.ru-ru.resx
Generated/GoogleSheets/Units.Designer.cs
Generated code can be used like this:
using MyGame.Generated.GoogleSheets;
var archer = Units.Archer;
ResX columns:
Nameis required.Neutral,Neutral Value, orNeutralValueis required.Neutral Commentis optional.- Culture columns are named by culture, for example
ru-ru. - Culture comment columns can be named like
ru-ru Commentorru-ruComment.
MSBuild Properties
| Property | Default | Description |
|---|---|---|
AlRevolverGoogleSheetsEnabled |
false |
Enables generation before PrepareResources. |
AlRevolverGoogleSheetsSpreadsheetId |
empty | Required when enabled. |
AlRevolverGoogleSheetsCredentialsFile |
env fallback | Service account JSON file. |
AlRevolverGoogleSheetsOutputDirectory |
$(MSBuildProjectDirectory)\Generated\GoogleSheets |
Base generated output directory. |
AlRevolverGoogleSheetsOutputJson |
$(AlRevolverGoogleSheetsOutputDirectory)\tables.json |
JSON output path. |
AlRevolverGoogleSheetsResxOutputDirectory |
$(AlRevolverGoogleSheetsOutputDirectory) |
ResX and designer output directory. |
AlRevolverGoogleSheetsResourceNamespace |
$(RootNamespace).Generated.GoogleSheets |
Namespace for generated designer classes. |
AlRevolverGoogleSheetsIgnoredColumns |
D |
Columns ignored for regular JSON sheets. Supports addresses like D, AA, or numeric indexes. |
AlRevolverGoogleSheetsHeaderRow |
1 |
Header row number. |
AlRevolverGoogleSheetsIndentJson |
true |
Writes formatted JSON. |
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
This package is not used by any popular GitHub repositories.