Exemplo n.º 1
0
        public override void Setup(DotNetCoreContext context)
        {
            GitVersionTool.Install(context);

            context.Target                       = context.Argument("target", "Default");
            context.Configuration                = context.Argument("configuration", "Release");
            context.SolutionRoot                 = context.FileSystem.GetDirectory(".").Path.MakeAbsolute(context.Environment);
            context.BuildVersion                 = BuildVersion.Calculate(context);
            context.Artifacts                    = context.Argument("artifacts", "./artifacts");
            context.NugetDefaultPushSourceUrl    = GetEnvOrArg(context, "nugetDefaultPushSourceUrl", "NUGET_DEFAULT_PUSH_SOURCE_URL");
            context.NugetDefaultPushSourceApiKey = GetEnvOrArg(context, "NUGET_DEFAULT_PUSH_SOURCE_URL_API_KEY", "nugetDefaultPushSourceApiKey");

            if (!context.HasArgument("solutionFilePath"))
            {
                var slnPaths = context.Globber.Match("*.sln", x => true).Where(x => !x.FullPath.EndsWith("Build.sln", System.StringComparison.OrdinalIgnoreCase));

                if (slnPaths != null && slnPaths.Count() == 1)
                {
                    context.SolutionFilePath = slnPaths.Single().FullPath;
                }
                else if (slnPaths != null && slnPaths.Count() > 1)
                {
                    throw new CakeException("More than 1 sln files found. Specify the sln file to used with the solutionFilePath argument.");
                }
            }
            else
            {
                context.SolutionFilePath = context.Argument <string>("solutionFilePath", null);
            }

            if (context.SolutionFilePath != null)
            {
                context.Information("Using solution: {0}", context.SolutionFilePath.FullPath);
                var slnResult = context.ParseSolution(context.SolutionFilePath);
                context.Projects = slnResult.Projects.Where(x => !x.Path.FullPath.EndsWith("Solution Items")).Select(x => new Project(x.Path, context.ParseProject(x.Path, context.Configuration))).ToList().AsReadOnly();
            }
            else
            {
                context.Projects = new Project[0];
            }

            var buildSystem = context.BuildSystem();

            context.IsLocalBuild = buildSystem.IsLocalBuild;

            context.DirectoriesToClean = new DirectoryPath[] { context.Artifacts };

            context.Verbose("\n\nDumping context...\n\n{0}", context.ToString());
        }