Exemplo n.º 1
0
        /// <summary>
        /// Increases the version.
        /// </summary>
        /// <param name="selectedItems">The selected items.</param>
        /// <param name="versionInfo">The version information.</param>
        /// <returns>IList<ResultInfo /><ProjectInfo /><ReferAssemblyInfo />&gt;&gt;.</returns>
        public IList <ResultInfo <NugetInfo <RefNugetInfo> > > IncreaseVersion(IList <NugetInfo <RefNugetInfo> > selectedItems, VersionInfo versionInfo)
        {
            Logger.Debug("IncreaseVersion <- Enter");
            try
            {
                var resultInfo = new List <ResultInfo <NugetInfo <RefNugetInfo> > >();
                foreach (var item in selectedItems)
                {
                    var refNugetName = item.Name;
                    foreach (var childItem in item.Items)
                    {
                        var assemblyResult = new ResultInfo <NugetInfo <RefNugetInfo> >(childItem)
                        {
                            SourceProjectName = refNugetName
                        };

                        try
                        {
                            var changResult = VSProjectHelper.ChangeRefNugetVersion(childItem.Path, refNugetName, versionInfo.Version);
                            if (!changResult)
                            {
                                assemblyResult.Error = $"Can not change reference version for assembly {refNugetName} with version=[{versionInfo.Version}]";
                            }
                        }
                        catch (Exception ex)
                        {
                            assemblyResult.Error = ex.Message;
                        }
                        resultInfo.Add(assemblyResult);
                    }
                }

                Logger.Debug("IncreaseVersion -> Leave");
                return(resultInfo);
            }
            catch (Exception ex)
            {
                Logger.Error($"IncreaseVersion - Exception: {ex.Message}", ex);
                throw;
            }
        }