コード例 #1
0
        public override void RunBuild(FilePath solution)
        {
            if (!BuildsOnCurrentPlatform)
            {
                CakeContext.Information("Solution is not configured to build on this platform: {0}", SolutionPath);
                return;
            }

            CakeContext.MSBuild(solution, c => {
                c.Configuration   = Configuration;
                c.MSBuildPlatform = MSBuildPlatform;

                if (!string.IsNullOrEmpty(Platform))
                {
                    c.Properties["Platform"] = new[] { Platform }
                }
                ;

                if (Targets != null && Targets.Any())
                {
                    foreach (var t in Targets)
                    {
                        c.Targets.Add(t);
                    }
                }

                if (Properties != null && Properties.Any())
                {
                    foreach (var kvp in Properties)
                    {
                        c.Properties.Add(kvp.Key, kvp.Value);
                    }
                }
            });
        }
コード例 #2
0
        public virtual void BuildSolution()
        {
            if (!BuildsOnCurrentPlatform)
            {
                CakeContext.Information("Solution is not configured to build on this platform: {0}", SolutionPath);
                return;
            }

            if (PreBuildAction != null)
            {
                PreBuildAction();
            }

            if (RestoreComponents)
            {
                CakeContext.RestoreComponents(SolutionPath, new XamarinComponentRestoreSettings());
            }

            CakeContext.NuGetRestore(SolutionPath, new NuGetRestoreSettings {
                Source = BuildSpec.NuGetSources.Select(s => s.Url).ToList()
            });

            RunBuild(SolutionPath);

            if (PostBuildAction != null)
            {
                PostBuildAction();
            }
        }
コード例 #3
0
ファイル: VersionService.cs プロジェクト: devlead/Aero
        private void UpdateCsProjFile(FilePath filePath, string version)
        {
            if (!CakeContext.XmlPeek(filePath, "/Project/@Sdk").StartsWith("Microsoft.NET.Sdk"))
            {
                return;
            }

            const string semver = @"^(\d+\.\d+\.\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$";
            var          regex  = new Regex(semver);
            var          match  = regex.Match(version);

            if (match.Success)
            {
                version = string.IsNullOrWhiteSpace(match.Groups[3].Value) ? match.Groups[1].Value : $"{match.Groups[1]}.{match.Groups[3]}";
            }
            else
            {
                //We either have Major.Minor.Build.Rev or yyMMdd.Rev from VSTS build
                //When we have yyMMdd.Rev, then we change it to yy.MM.dd.Rev
                var segments = version.Split('.');
                if (segments.Length == 2)
                {
                    version = $"{segments[0].Substring(0, 2)}.{segments[0].Substring(2, 2)}.{segments[0].Substring(4, 2)}.{segments[1]}";
                }
            }

            CakeContext.Information($"Update csproj for version. Version: {version}, File: {filePath}");
            CakeContext.XmlPoke(filePath, "/Project/PropertyGroup/AssemblyVersion", version);
            CakeContext.XmlPoke(filePath, "/Project/PropertyGroup/FileVersion", version);
            CakeContext.XmlPoke(filePath, "/Project/PropertyGroup/Version", version);
        }
コード例 #4
0
        public virtual void CopyOutput()
        {
            if (OutputFiles == null)
            {
                return;
            }

            if (!BuildsOnCurrentPlatform)
            {
                return;
            }

            foreach (var fileCopy in OutputFiles)
            {
                FilePath targetFileName;

                var targetDir = fileCopy.ToDirectory ?? OutputDirectory;
                CakeContext.CreateDirectory(targetDir);

                if (fileCopy.NewFileName != null)
                {
                    targetFileName = targetDir.CombineWithFilePath(fileCopy.NewFileName);
                }
                else
                {
                    targetFileName = targetDir.CombineWithFilePath(fileCopy.FromFile.GetFilename());
                }

                var srcAbs  = CakeContext.MakeAbsolute(fileCopy.FromFile);
                var destAbs = CakeContext.MakeAbsolute(targetFileName);

                var sourceTime = System.IO.File.GetLastAccessTime(srcAbs.ToString());
                var destTime   = System.IO.File.GetLastAccessTime(destAbs.ToString());

                CakeContext.Information("Target Dir: Exists? {0}, {1}", CakeContext.DirectoryExists(targetDir), targetDir);

                CakeContext.Information("Copy From: Exists? {0}, Dir Exists? {1}, Modified: {2}, {3}",
                                        CakeContext.FileExists(srcAbs), CakeContext.DirectoryExists(srcAbs.GetDirectory()), sourceTime, srcAbs);
                CakeContext.Information("Copy To:   Exists? {0}, Dir Exists? {1}, Modified: {2}, {3}",
                                        CakeContext.FileExists(destAbs), CakeContext.DirectoryExists(destAbs.GetDirectory()), destTime, destAbs);

                if (sourceTime > destTime || !CakeContext.FileExists(destAbs))
                {
                    CakeContext.Information("Copying File: {0} to {1}", srcAbs, targetDir);
                    CakeContext.CopyFileToDirectory(srcAbs, targetDir);
                }
            }
        }
コード例 #5
0
        public override void RunBuild(FilePath solution)
        {
            if (!BuildsOnCurrentPlatform)
            {
                CakeContext.Information("Solution is not configured to build on this platform: {0}", SolutionPath);
                return;
            }

            //if (CakeContext.IsRunningOnUnix ()) {
            //    CakeContext.MDToolBuild (solution, c => {
            //        c.Configuration = Configuration;
            //    });
            //} else {
            base.RunBuild(solution);
            //}
        }