using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Sharpmake;
namespace JustDance.Tools.Helpers
{
///
/// Adds the JetBrains settings for each solution generated.
///
public class JetBrainsSettingsDeployer
{
public static void Deploy(List solutions)
{
var sourceSettings = Path.Combine(Globals.BranchRoot, @"build\sharpmake\DefaultSettings.DotSettings");
var sourceDate = File.GetLastWriteTime(sourceSettings);
foreach (var solution in solutions.OfType())
{
foreach (var solutionFile in solution.SolutionFilesMapping.Keys)
{
var solutionSettings = solutionFile + ".sln.DotSettings";
try
{
FileInfo fileInfo = new FileInfo(solutionSettings);
if (fileInfo.Exists)
{
fileInfo.IsReadOnly = false;
}
if (fileInfo.LastWriteTime < sourceDate)
{
File.Copy(sourceSettings, solutionSettings, overwrite: true);
}
}
catch (Exception ex)
{
Console.WriteLine("warning: was not able to override jetbrains settings file {0}. Details: {1}", solutionSettings, ex.Message);
}
}
}
}
}
}