Skip to content

Commit

Permalink
Merge pull request #271 from dansiegel/update-gitignore
Browse files Browse the repository at this point in the history
Update .gitignore
  • Loading branch information
dansiegel authored Jul 7, 2021
2 parents e067c3a + d769395 commit 9663ae3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ The Mobile.BuildTools relies a lot on JSON configurations because JSON is easy f

| FileName | Schema Url |
|:--------:|:----------:|
| secrets.json | n/a - JSON Dictionary |
| appsettings.json | n/a - JSON Dictionary |
| buildtools.json | https://mobilebuildtools.com/schemas/v2/buildtools.schema.json |
| {imageName}.json | https://mobilebuildtools.com/schemas/v2/resourceDefinition.schema.json |

## Secrets.json
## appsettings.json

Everyone has a different opinion of how they would like to set things up. While the Mobile.BuildTools is opinionated in certain ways, we also try to make efforts to meet developers where their needs are giving you some flexibility in configuration. Within a CI environment, the Mobile.BuildTools relies on Environment Variables to map values you need in your app. However this is a bit of a pain to deal with for local app development. The Mobile.BuildTools has long relied on a `secrets.json` file containing the dictionary values of the various variables you need for your build. Version 2.0 has added a few benefits to this allowing you to now pick and choose which file directory you would like the secrets.json to live in. This can be any directory from the directory where your Solution file is located up to the Project directory. This can be particularly helpful when you may be using the Mobile.BuildTools to supply values across multiple projects or even where you may be replacing certain values in your AndroidManifest.xml or Info.plist.
Everyone has a different opinion of how they would like to set things up. While the Mobile.BuildTools is opinionated in certain ways, we also try to make efforts to meet developers where their needs are giving you some flexibility in configuration. Within a CI environment, the Mobile.BuildTools relies on Environment Variables to map values you need in your app. However this is a bit of a pain to deal with for local app development. The Mobile.BuildTools has long relied on a `secrets.json` file containing the dictionary values of the various variables you need for your build. With version 2.0 we have deprecated `secrets.json` in favor of `appsettings.json`. Additionally we hav added a few benefits to this allowing you to now pick and choose which file directory you would like the appsettings.json to live in. This can be any directory from the directory where your Solution file is located up to the Project directory. This can be particularly helpful when you may be using the Mobile.BuildTools to supply values across multiple projects or even where you may be replacing certain values in your AndroidManifest.xml or Info.plist.

## BuildTools.json

Expand Down
5 changes: 3 additions & 2 deletions docs/credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ While the Mobile.BuildTools does not add any external dependencies to your proje
| MSBuild | MIT | [microsoft/msbuild](https://github.com/microsoft/msbuild) |
| Newtonsoft.Json | MIT | [JamesNK/Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) |
| Microsoft.Web.Xdt* | Apache | [aspnet/xdt](https://github.com/aspnet/xdt) |
| SixLabors.ImageSharp | Apache | [SixLabors/ImageSharp/](https://github.com/SixLabors/ImageSharp/) |
| Svg.Skia | MIT | [wieslawsoltes/Svg.Skia](https://github.com/wieslawsoltes/Svg.Skia)
| SkiaSharp | MIT | [mono/SkiaSharp](https://github.com/mono/SkiaSharp) |

!!! note Note
Microsoft.Web.Xdt is the only reference added to projects, if using the Mobile.BuildTools.Configuration package. There is never any bloat added by the core Mobile.BuildTools package to your applications. Despite being from the aspnet team this package does not bring in any additional references.
Microsoft.Web.Xdt is the only reference added to projects, if using the Mobile.BuildTools.Configuration package. There is never any bloat added by the core Mobile.BuildTools package to your applications. Despite being from the aspnet team this package does not bring in any additional references.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TemplatedManifest : ToolItem
[JsonProperty("variablePrefix", NullValueHandling = NullValueHandling.Ignore)]
public string VariablePrefix { get; set; }

[Description("If set to true, this will generate a build time error if a token is found which does not have a value in the environment or secrets.json.")]
[Description("If set to true, this will generate a build time error if a token is found which does not have a value in the environment or appsettings.json.")]
[DefaultValue(false)]
[JsonProperty("missingTokensAsErrors", NullValueHandling = NullValueHandling.Ignore)]
public bool MissingTokensAsErrors { get; set; }
Expand Down
34 changes: 23 additions & 11 deletions src/Mobile.BuildTools.Reference/Utils/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ public static void SaveDefaultConfig(string path)
},
Images = new ImageResize
{
ConditionalDirectories = null,
Directories = null
ConditionalDirectories = new Dictionary<string, IEnumerable<string>>
{
{ "Debug", Array.Empty<string>() },
{ "!Debug", Array.Empty<string>() },
{ "iOS", Array.Empty<string>() },
{ "Android", Array.Empty<string>() },
},
Directories = new List<string>()
},
Manifests = new TemplatedManifest
{
Expand All @@ -61,6 +67,14 @@ public static void SaveDefaultConfig(string path)
FileName = "ReleaseNotes.txt",
MaxCommit = 10,
MaxDays = 7
},
Environment = new EnvironmentSettings
{
Configuration = new Dictionary<string, Dictionary<string, string>>
{
{ "Debug", new Dictionary<string, string>() }
},
Defaults = new Dictionary<string, string>()
}
};

Expand All @@ -85,21 +99,19 @@ public static void SaveDefaultConfig(string path)

#if !DEBUG // Do not generate .gitignore for local debug builds
var requiredContents = @"# Mobile.BuildTools
secrets.json
secrets.*.json
appsettings.json
appsettings.*.json
";
var gitignoreFile = Path.Combine(path, ".gitignore");
if (File.Exists(gitignoreFile))
if (!File.Exists(gitignoreFile))
{
if(!File.ReadAllText(gitignoreFile).Contains(Constants.SecretsJsonFileName))
{
File.AppendAllText(gitignoreFile, $"\n\n{requiredContents}");
}
File.WriteAllText(gitignoreFile, requiredContents);
}
else
else if(!File.ReadAllText(gitignoreFile).Contains(Constants.SecretsJsonFileName))
{
File.WriteAllText(gitignoreFile, requiredContents);
File.AppendAllText(gitignoreFile, $"\n\n{requiredContents}");
}

#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void GeneratesValidClass(string secretsFile, PropertyType propertyType, T
Directory.Delete(testDirectory, true);

Directory.CreateDirectory(testDirectory);
File.Copy(Path.Combine("Templates", "Secrets", secretsFile), Path.Combine(testDirectory, "secrets.json"));
File.Copy(Path.Combine("Templates", "Secrets", secretsFile), Path.Combine(testDirectory, "appsettings.json"));

var config = GetConfiguration($"{nameof(GeneratesValidClass)}-{expectedType.Name}");
config.SolutionDirectory = config.ProjectDirectory = testDirectory;
Expand Down

0 comments on commit 9663ae3

Please sign in to comment.