예제 #1
0
        public override bool Execute()
        {
            Log.LogMessage(MessageImportance.Low, "AutoVersion task started");
            try {
                var proj = XDocument.Load(ProjectPath, LoadOptions.PreserveWhitespace);

                var settings = LoadSettingsFromFile(Path.ChangeExtension(ProjectPath, ".autoVersion")) ??
                               LoadSettingsFromFile(Path.Combine(Path.GetDirectoryName(ProjectPath), ".autoVersion")) ??
                               new AutoVersionSettings {
                    BumpTypeVersionPart1 = BumpTypeVersionPart1,
                    BumpTypeVersionPart2 = BumpTypeVersionPart2,
                    BumpTypeVersionPart3 = BumpTypeVersionPart3,
                    BumpTypeVersionPart4 = BumpTypeVersionPart4
                                           //LabelDigits = LabelDigits == 0 ? AutoVersionSettings.DefaultLabelDigits : LabelDigits
                };

                Log.LogMessage(MessageImportance.Low, $"AutoVersion settings = {JObject.FromObject(settings)}");
                var autoVersion = new AutoVersion(ProjectPath, Configuration);
                if (autoVersion.TryAutoVersion(proj, settings))
                {
                    Log.LogMessage(MessageImportance.Low, "Saving project file");
                    using (var stream = File.Create(ProjectPath)) {
                        stream.Flush();
                        proj.Save(stream);
                    }
                }
            } catch (Exception e) {
                Log.LogErrorFromException(e);
                return(false);
            }
            return(true);
        }
예제 #2
0
        public static void SetProjectVersionInfo2(string projectPath, string configuration)
        {
            Console.WriteLine("AutoVersion task started");
            var xmlProject  = XDocument.Load(projectPath, LoadOptions.PreserveWhitespace);
            var autoVersion = new AutoVersion(projectPath, configuration);

            if (autoVersion.TryAutoVersion(xmlProject))
            {
                Console.WriteLine("Saving project file");
                using (var stream = File.Create(projectPath)) {
                    stream.Flush();
                    xmlProject.Save(stream);
                }
            }
        }