async void Execute(object sender, EventArgs e) { if (!UserWantToProceed()) { return; } string solutionRoot = Path.GetDirectoryName(DTE.Solution.FullName); var manifestFile = Directory.EnumerateFiles(solutionRoot, "*.vsixmanifest", SearchOption.AllDirectories).FirstOrDefault(); var manifest = await VsixManifestParser.FromFileAsync(manifestFile); string assembly = Assembly.GetExecutingAssembly().Location; string root = Path.GetDirectoryName(assembly); string dir = Path.Combine(root, "Misc\\Resources\\Appveyor"); foreach (var src in Directory.EnumerateFiles(dir)) { string fileName = Path.GetFileName(src); string dest = Path.Combine(solutionRoot, fileName); if (!File.Exists(dest)) { var content = await PrepareForGitHub.ReplaceTokens(src, manifest); string manifestCs = Path.ChangeExtension(manifestFile, ".cs"); string versionFile = "{source.extension.cs}"; string relative = manifestCs.Replace(solutionRoot, string.Empty).Trim('\\'); content = content.Replace(versionFile, relative); if (File.Exists(manifestCs)) { content = content.Replace("#- ps: Vsix-TokenReplacement", "- ps: Vsix-TokenReplacement"); } File.WriteAllText(dest, content); PrepareForGitHub.AddFileToSolutionFolder(dest, (Solution2)DTE.Solution); } } }
public static void Initialize(Package package) { Instance = new PrepareForGitHub(package); }