AlRevolver.GoogleSheets
1.1.0
dotnet add package AlRevolver.GoogleSheets --version 1.1.0
NuGet\Install-Package AlRevolver.GoogleSheets -Version 1.1.0
<PackageReference Include="AlRevolver.GoogleSheets" Version="1.1.0" />
<PackageVersion Include="AlRevolver.GoogleSheets" Version="1.1.0" />
<PackageReference Include="AlRevolver.GoogleSheets" />
paket add AlRevolver.GoogleSheets --version 1.1.0
#r "nuget: AlRevolver.GoogleSheets, 1.1.0"
#:package AlRevolver.GoogleSheets@1.1.0
#addin nuget:?package=AlRevolver.GoogleSheets&version=1.1.0
#tool nuget:?package=AlRevolver.GoogleSheets&version=1.1.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 |
Because the fourth header cell is empty, that column is ignored automatically:
{
"Units": [
{
"Name": "Archer",
"Hp": 100,
"Attack": 20,
"Type": "Range"
},
{
"Name": "Cavale",
"Hp": 100,
"Attack": 20,
"Type": "Cavalery"
}
]
}
Rules:
StartingIndexdefaults toA1; that cell is the first header cell.- Empty header cells are ignored.
- Explicitly 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.
Starting Index and Ignored Columns
StartingIndex controls where a sheet table begins. The value is the first header cell.
Examples:
<AlRevolverGoogleSheetsStartingIndex>A1</AlRevolverGoogleSheetsStartingIndex>
<AlRevolverGoogleSheetsStartingIndex>G13</AlRevolverGoogleSheetsStartingIndex>
<AlRevolverGoogleSheetsStartingIndex>Units:A1;Units.resx:G11</AlRevolverGoogleSheetsStartingIndex>
IgnoredColumns is empty by default. Use semicolon-separated absolute Google Sheet columns when you need to skip columns.
Examples:
<AlRevolverGoogleSheetsIgnoredColumns>Z;AA</AlRevolverGoogleSheetsIgnoredColumns>
<AlRevolverGoogleSheetsIgnoredColumns>Units:Z;Units:AA;Items:AA</AlRevolverGoogleSheetsIgnoredColumns>
Sheet-specific entries use : and match sheet names case-insensitively.
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. |
AlRevolverGoogleSheetsStartingIndex |
A1 |
First header cell. Supports global and sheet-specific values like G13 or Units:A1;Units.resx:G11. |
AlRevolverGoogleSheetsIgnoredColumns |
empty | Absolute columns ignored for regular JSON sheets. Supports global and sheet-specific values like Z;AA or Units:Z;Items:AA. |
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.