Esempio n. 1
0
        private void OnClick(object sender, EventArgs e)
        {
            if (sender == _uiAddTarget)
            {
                Xml.Settings.General.NuGet.Target target = new Xml.Settings.General.NuGet.Target()
                {
                    Name = "Name", Moniker = string.Format("Moniker {0}", Definitions.Constants.Random.Next(100))
                };

                GuiUtil.AddItem(target, _options.NuGetOptions.Targets, _uiTargets);
            }
            else if (sender == _uiRemoveTarget && _selectedTarget != null)
            {
                GuiUtil.RemoveItem(_selectedTarget, _options.NuGetOptions.Targets, _uiTargets);
            }
            else if (sender == _uiApplyChanges && _selectedTarget != null)
            {
                foreach (Xml.Settings.General.NuGet.Target t in _options.NuGetOptions.Targets)
                {
                    if (t.Moniker == _uiCurrentTargetMoniker.Text && t != _selectedTarget)
                    {
                        MessageBox.Show("A target with the same moniker exists already, please change the moniker");
                        return;
                    }
                }

                _selectedTarget.Name    = _uiCurrentTargetName.Text;
                _selectedTarget.Moniker = _uiCurrentTargetMoniker.Text;

                _uiApplyChanges.Enabled = false;

                GuiUtil.RefreshItems(_uiTargets);
            }
        }
Esempio n. 2
0
        public CreateNuGetTarget(string moniker)
        {
            InitializeComponent();

            _uiMoniker.Text = moniker;

            Target         = new Xml.Settings.General.NuGet.Target();
            Target.Moniker = moniker;
        }
Esempio n. 3
0
        /// <summary>
        /// prepares the project so all the needed projects information are known
        /// <para>those information is stored in the given transit and container object</para>
        /// <para>this method is intended to be used after the prepare method has been called</para>
        /// </summary>
        /// <param name="activeProject">project to analyse, must not be null</param>
        /// <param name="packageInfo">transit object used to store the analysed information, must not be null</param>
        /// <param name="container">container object which contains information needed to analyse the project,</param>
        /// <returns>null if the analyse process was successfull, otherwise the error message is returned</returns>
        private void AnalyseProject(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation)
        {
            LoggingManager.Instance.Logger.Debug("analsye project started");

            if (activeProject == null)
            {
                throw new ArgumentNullException("activeProject", "given project must not be null");
            }
            if (packageInfo == null)
            {
                throw new ArgumentNullException("transit", "given transit must not be null");
            }
            if (projectInformation == null)
            {
                throw new ArgumentNullException("projectInformation", "given projectInformation must not be null");
            }

            string monikerValue = null;

            //----- analyse the project dependent on the identifier
            AnalyseAssembly(activeProject, packageInfo, projectInformation, out monikerValue);

            //-----get the nuget target
            Xml.Settings.General.NuGet.Target nuGetTarget = null;
            try
            {
                nuGetTarget = OptionsManager.Instance.Configuration.GeneralOptions.NuGetOptions.Targets.First(tf => tf.Moniker == monikerValue);
            }
            catch (InvalidOperationException ex)
            {
                throw new UnkownMonikerException(monikerValue, string.Format("given moniker {0} is not known", monikerValue), ex);
            }

            ChangeNuSpec(activeProject, packageInfo);

            DetermineBuildOptions(activeProject, packageInfo, projectInformation);

            DetermineNuSpecFiles(activeProject, packageInfo, projectInformation, nuGetTarget);

            DetermineNuSpecDependecies(activeProject, packageInfo);

            CheckNuSpecFile(activeProject, packageInfo);

            ValidatePackageInformation(packageInfo);

            LoggingManager.Instance.Logger.Debug("analsye project finished");
        }
Esempio n. 4
0
        private void OnChange(object sender, EventArgs e)
        {
            if (!_blockEvents)
            {
                if (sender == _uiTargets)
                {
                    _selectedTarget = (Xml.Settings.General.NuGet.Target)_uiTargets.SelectedItem;

                    _blockEvents = true;

                    if (_selectedTarget != null)
                    {
                        _isKown = OptionsManager.Instance.KownNuGetTargets.Contains(_selectedTarget);

                        _uiCurrentTargetName.Text     = _selectedTarget.Name;
                        _uiCurrentTargetName.ReadOnly = _isKown;
                        _uiCurrentTargetName.Enabled  = true;

                        _uiCurrentTargetMoniker.Text     = _selectedTarget.Moniker;
                        _uiCurrentTargetMoniker.ReadOnly = _isKown;
                        _uiCurrentTargetMoniker.Enabled  = true;

                        _uiRemoveTarget.Enabled = !_isKown;
                    }
                    else
                    {
                        _uiCurrentTargetName.Text    = null;
                        _uiCurrentTargetName.Enabled = false;

                        _uiCurrentTargetMoniker.Text    = null;
                        _uiCurrentTargetMoniker.Enabled = false;

                        _uiRemoveTarget.Enabled = false;
                    }

                    _blockEvents = false;

                    _uiApplyChanges.Enabled = false;
                }
                else if ((sender == _uiCurrentTargetName || sender == _uiCurrentTargetMoniker) && _selectedTarget != null && !_isKown)
                {
                    _uiApplyChanges.Enabled = (_selectedTarget.Name != _uiCurrentTargetName.Text || _selectedTarget.Moniker != _uiCurrentTargetMoniker.Text);
                }
            }
        }
Esempio n. 5
0
        private void OnChange(object sender, EventArgs e)
        {
            if (!_blockEvents)
            {
                if (sender == _uiTargets)
                {
                    _selectedTarget = (Xml.Settings.General.NuGet.Target)_uiTargets.SelectedItem;

                    _blockEvents = true;

                    if (_selectedTarget != null)
                    {
                        _isKown = OptionsManager.Instance.KownNuGetTargets.Contains(_selectedTarget);

                        _uiCurrentTargetName.Text = _selectedTarget.Name;
                        _uiCurrentTargetName.ReadOnly = _isKown;
                        _uiCurrentTargetName.Enabled = true;

                        _uiCurrentTargetMoniker.Text = _selectedTarget.Moniker;
                        _uiCurrentTargetMoniker.ReadOnly = _isKown;
                        _uiCurrentTargetMoniker.Enabled = true;

                        _uiRemoveTarget.Enabled = !_isKown;
                    }
                    else
                    {
                        _uiCurrentTargetName.Text = null;
                        _uiCurrentTargetName.Enabled = false;

                        _uiCurrentTargetMoniker.Text = null;
                        _uiCurrentTargetMoniker.Enabled = false;

                        _uiRemoveTarget.Enabled = false;
                    }

                    _blockEvents = false;

                    _uiApplyChanges.Enabled = false;
                }
                else if ((sender == _uiCurrentTargetName || sender == _uiCurrentTargetMoniker) && _selectedTarget != null && !_isKown)
                {
                    _uiApplyChanges.Enabled = (_selectedTarget.Name != _uiCurrentTargetName.Text || _selectedTarget.Moniker != _uiCurrentTargetMoniker.Text);
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// determines the nuspec files to add from the project
        /// </summary>
        private void DetermineNuSpecFiles(Project activeProject, PackageInformation packageInfo, ProjectInformation projectInformation, Xml.Settings.General.NuGet.Target nuGetTarget)
        {
            LoggingManager.Instance.Logger.Debug("determine nuspec files started");

            //-----add the assembly file
            packageInfo.NuSpecPackage.Files = new List <Xml.NuGet.NuSpec.File>();
            packageInfo.NuSpecPackage.Files.Add(new Xml.NuGet.NuSpec.File()
            {
                Source = Path.Combine(packageInfo.Build.BuildPath, packageInfo.OutputFileName), Target = string.Format(@"lib\{0}", nuGetTarget.Name)
            });

            //-----add the pdb file only if the debug useage is used and the value is known
            if (packageInfo.ProjectOptions.MsBuildOptions.Usage.DebugInfo.Useage != Enumerations.Useage.None)
            {
                string source = Path.Combine(packageInfo.Build.BuildPath, StringUtil.ReplaceLastOccurrence(packageInfo.OutputFileName, Resources.ExtensionDLL, Resources.ExtensionPDB));

                Xml.NuGet.NuSpec.File pdbFile = new Xml.NuGet.NuSpec.File()
                {
                    Source = source, Target = string.Format(@"lib\{0}", nuGetTarget.Name)
                };

                packageInfo.Build.PdbFiles.Add(pdbFile);

                if (packageInfo.Build.DebugInfo == Resources.DebugInfoPdbOnly || packageInfo.Build.DebugInfo == Resources.DebugInfoFull)
                {
                    packageInfo.NuSpecPackage.Files.Add(pdbFile);
                }
            }

            //HACK this is needed since VB does not implement the documentation file the way CS does it, need to find a work arround
            if (projectInformation.Identifier == Enumerations.ProjectIdentifier.CS)
            {
                //include documentation files if needed
                foreach (string documentationFileUrl in ExtensionUtil.GetFilenames(activeProject.ConfigurationManager.ActiveConfiguration, Definitions.Constants.DocumentaionOutputGroupCanonicalName))
                {
                    Xml.NuGet.NuSpec.File documentationFile = new Xml.NuGet.NuSpec.File()
                    {
                        Source = documentationFileUrl, Target = string.Format(@"lib\{0}", nuGetTarget.Name)
                    };

                    if (packageInfo.Build.DocumentationFile == null)
                    {
                        packageInfo.Build.DocumentationFile = documentationFile;
                    }

                    packageInfo.NuSpecPackage.Files.Add(documentationFile);
                }
            }

            //-----get all the includeable item here
            if (packageInfo.ProjectOptions.NuGetOptions.NuSpecOptions.Files.FileIncludes.Count > 0)
            {
                if (projectInformation.Identifier == Enumerations.ProjectIdentifier.CS || projectInformation.Identifier == Enumerations.ProjectIdentifier.VB)
                {
                    AddNuSpecFilesCSharpVisualBasic(activeProject.ProjectItems, packageInfo, projectInformation);
                }
            }

            LoggingManager.Instance.Logger.Debug("determine nuspec files finished");
        }
Esempio n. 7
0
        private void OnClick(object sender, EventArgs e)
        {
            if (sender == _uiAddTarget)
            {
                Xml.Settings.General.NuGet.Target target = new Xml.Settings.General.NuGet.Target() { Name = "Name", Moniker = string.Format("Moniker {0}", Definitions.Constants.Random.Next(100)) };

                GuiUtil.AddItem(target, _options.NuGetOptions.Targets, _uiTargets);
            }
            else if (sender == _uiRemoveTarget && _selectedTarget != null)
            {
                GuiUtil.RemoveItem(_selectedTarget, _options.NuGetOptions.Targets, _uiTargets);
            }
            else if (sender == _uiApplyChanges && _selectedTarget != null)
            {
                foreach (Xml.Settings.General.NuGet.Target t in _options.NuGetOptions.Targets)
                    if (t.Moniker == _uiCurrentTargetMoniker.Text && t != _selectedTarget)
                    {

                        MessageBox.Show("A target with the same moniker exists already, please change the moniker");
                        return;
                    }

                _selectedTarget.Name = _uiCurrentTargetName.Text;
                _selectedTarget.Moniker = _uiCurrentTargetMoniker.Text;

                _uiApplyChanges.Enabled = false;

                GuiUtil.RefreshItems(_uiTargets);
            }
        }