示例#1
0
        private void createNuspec(string projectFile, bool force = false)
        {
            var nugetCommands = new NuGetCommands(output);

            nugetCommands.CreateNuspec(projectFile, force).ContinueWith(t =>
            {
                try
                {
                    var code = t.Result;
                    if (code != 0)
                    {
                        VsShellUtilities.ShowMessageBox(
                            this,
                            "Creation of nuspec file failed! See output window for further information.",
                            "Create NuSpec",
                            OLEMSGICON.OLEMSGICON_WARNING,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                    else
                    {
                        var nuspecFile = Path.GetFileNameWithoutExtension(projectFile) + ".nuspec";
                        var dir        = Path.GetDirectoryName(projectFile);

                        VsShellUtilities.OpenDocument(this, Path.Combine(dir, nuspecFile));
                    }
                }
                catch (Exception ex)
                {
                    displayException(ex, "Creation of nuspec file failed! See output window for further information.", "Create NuSpec");
                }
            });
        }
示例#2
0
        private void clearCacheCallback(object sender, EventArgs e)
        {
            var nugetCommands = new NuGetCommands(output);

            nugetCommands.ClearPackageCache().ContinueWith(t =>
            {
                try
                {
                    var code = t.Result;
                    if (code != 0)
                    {
                        VsShellUtilities.ShowMessageBox(
                            this,
                            "Clear NuGet cache failed! See output window for further information.",
                            "Clear NuGet Cache",
                            OLEMSGICON.OLEMSGICON_WARNING,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                }
                catch (Exception ex)
                {
                    VsShellUtilities.ShowMessageBox(
                        this,
                        "Clear NuGet cache failed!" + ex.Message + "." + Environment.NewLine + "See output window for further information.",
                        "Clear NuGet Cache",
                        OLEMSGICON.OLEMSGICON_WARNING,
                        OLEMSGBUTTON.OLEMSGBUTTON_OK,
                        OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                    output.WriteError(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
                }
            });
        }
示例#3
0
        private void pushPackage(string packageFile)
        {
            // Open document
            var nugetCommands = new NuGetCommands(output);

            nugetCommands.PushPackage(packageFile).ContinueWith(t =>
            {
                try
                {
                    var code = t.Result;
                    if (code != 0)
                    {
                        VsShellUtilities.ShowMessageBox(
                            this,
                            "Push of package failed! See output window for further information.",
                            "Push package",
                            OLEMSGICON.OLEMSGICON_WARNING,
                            OLEMSGBUTTON.OLEMSGBUTTON_OK,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                    }
                    else
                    {
                        var decision = VsShellUtilities.ShowMessageBox(
                            this,
                            "Package pushed. Delete it?",
                            "Delete Package",
                            OLEMSGICON.OLEMSGICON_QUERY,
                            OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                            OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                        if (decision == 6)
                        {
                            File.Delete(packageFile);
                        }
                    }
                }
                catch (Exception ex)
                {
                    displayException(ex, "Push of package failed! See output window for further information.", "Push Package");
                }
            });
        }
示例#4
0
        public void CreatePackage(string projectFile, string assemblyName)
        {
            try
            {
                var projectDir = Path.GetDirectoryName(projectFile);
                new VersionDialog(this).Show(projectDir, (version) =>
                {
                    var nugetCommands = new NuGetCommands(output);
                    nugetCommands.CreatePackage(projectFile, projectDir, assemblyName, version).ContinueWith(t =>
                    {
                        try
                        {
                            var code = t.Result;
                            if (code != 0)
                            {
                                VsShellUtilities.ShowMessageBox(
                                    this,
                                    "Creation of package file failed! See output window for further information.",
                                    "Create Package",
                                    OLEMSGICON.OLEMSGICON_WARNING,
                                    OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                    OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
                            }
                            else
                            {
                                if (nugetCommands.LastCreatedFile != null)
                                {
                                    var decision = VsShellUtilities.ShowMessageBox(
                                        this,
                                        "Package created. Push it?",
                                        "Create Package",
                                        OLEMSGICON.OLEMSGICON_QUERY,
                                        OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                                        OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                                    if (decision == 6)
                                    {
                                        pushPackage(nugetCommands.LastCreatedFile.FullName);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            VsShellUtilities.ShowMessageBox(
                                this,
                                "Creation of package file failed!" + ex.Message + "." + Environment.NewLine + "See output window for further information.",
                                "Create Package",
                                OLEMSGICON.OLEMSGICON_WARNING,
                                OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

                            output.WriteError(ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
                        }
                    });
                });
            }
            catch (Exception e)
            {
                displayException(e);
            }
        }