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\\GitHub"); 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 ReplaceTokens(src, manifest); File.WriteAllText(dest, content); if (_visible.Contains(fileName)) { AddFileToSolutionFolder(dest, (Solution2)DTE.Solution); } } } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private async void MenuItemCallbackAsync(object sender, EventArgs e) { //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); //string title = "PrepForGit"; //// Show a message box to prove we were here //VsShellUtilities.ShowMessageBox( // this.ServiceProvider, // message, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); 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, "Resources\\GitHub"); 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 ReplaceTokens(src, manifest); File.WriteAllText(dest, content); if (_visible.Contains(fileName)) { AddFileToSolutionFolder(dest, (Solution2)DTE.Solution); } } } }
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); } } }