Пример #1
0
        public static Version FetchBuildVersionFromFile(ITaskContext context)
        {
            string productRootDir         = context.Properties.Get(BuildProps.ProductRootDir, ".");
            string projectVersionFileName = context.Properties.Get <string>(BuildProps.ProjectVersionFileName, null);
            string productId = context.Properties.Get <string>(BuildProps.ProductId);

            IFetchBuildVersionTask task = new FetchBuildVersionFromFileTask(productRootDir, productId)
            {
                ProjectVersionFileName = projectVersionFileName
            };

            task.Execute(context);
            return(task.BuildVersion);
        }
        public void FetchBuildVersionFromFileVersionNotInFirstLineWithPrefixAndSufixTest()
        {
            var fileName = GetOsPlatform() == OSPlatform.Windows ? @"TestData\ReleaseNotes.md" : @"TestData/ReleaseNotes.md";

            Context.Properties.Set(BuildProps.ProductRootDir, ".");
            var task = new FetchBuildVersionFromFileTask();

            task.ProjectVersionFileName(fileName.ExpandToExecutingPath()).RemovePrefix("##").AllowSuffix();
            var buildVersion = task.Execute(Context);

            Assert.Equal(4, buildVersion.Major);
            Assert.Equal(5, buildVersion.Build);
            Assert.Equal(1, buildVersion.Minor);
            Assert.Equal(2, buildVersion.Revision);
        }
        public void FetchBuildVersionFromFileTest()
        {
            var fileName = GetOsPlatform() == OSPlatform.Windows ? @"TestData\Flubu.ProjectVersion.txt" : @"TestData/Flubu.ProjectVersion.txt";

            Context.Properties.Set(BuildProps.ProductRootDir, ".");
            var task = new FetchBuildVersionFromFileTask();

            task.ProjectVersionFileName(fileName.ExpandToExecutingPath());
            var buildVersion = task.Execute(Context);

            Assert.Equal(4, buildVersion.Major);
            Assert.Equal(5, buildVersion.Build);
            Assert.Equal(1, buildVersion.Minor);
            Assert.Equal(2, buildVersion.Revision);
        }