public static void SetUnity3DDependency(this ICakeContext context, Unity3DProjectOptions projectOptions, string dependencyName, string value) { string path = System.IO.Path.Combine(projectOptions.ProjectFolder.ToString(), "Packages/manifest.json"); var manifest = PackageManifest.ReadFile(path); bool hasChange = false; if (string.IsNullOrEmpty(value)) { if (manifest.dependencies.ContainsKey(dependencyName)) { // Clear Entry manifest.dependencies.Remove(dependencyName); hasChange = true; System.Console.WriteLine($"- {dependencyName}"); } } else { string currentValue; if (!manifest.dependencies.TryGetValue(dependencyName, out currentValue)) { // Add Entry manifest.dependencies.Add(dependencyName, value); hasChange = true; System.Console.WriteLine($"+ {dependencyName} => {value}"); } else if (currentValue != value) { // Update Entry manifest.dependencies[dependencyName] = value; hasChange = true; System.Console.WriteLine($" {dependencyName} => {value}"); } } if (hasChange) { PackageManifest.WriteFile(path, manifest); } }