Ejemplo n.º 1
0
        private static string GetProjectObjOutputDirectoryPath(
            this SolutionProject project,
            IProjectConfiguration config)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var relativeBase      = config.GetRelativeSlnFilePath().GetDirectory();
            var baseOutputPath    = $"{relativeBase.FullPath}/**/{project.Name}";
            var baseBinOutputPath = $"{baseOutputPath}/obj";

            var configPath    = string.IsNullOrWhiteSpace(config.Configuration) ? "/**" : $"/{config.Configuration}";
            var frameworkPath = string.IsNullOrWhiteSpace(config.Framework) ? string.Empty : $"/{config.Framework}";

            var binPath = $"{baseBinOutputPath}{configPath}{frameworkPath}";

            return(binPath);
        }
        private void RegisterBuildTasks(IProjectConfiguration projConfig)
        {
            this.Context.BuildTask(projConfig.ProjectAlias);

            this.Context.BuildTask("DotNetCoreBuild", false, projConfig.ProjectAlias)
            .Does(() =>
            {
                var buildSettings = new DotNetCoreBuildSettings
                {
                    Configuration = projConfig.Configuration,
                    Framework     = projConfig.Framework
                };

                this.Context.Debug($"Building {projConfig.GetRelativeSlnFilePath().FullPath}...");
                this.Context.DotNetCoreBuild(projConfig.GetRelativeSlnFilePath().FullPath, buildSettings);
            });
        }
        private void RegisterPreBuildTasks(IProjectConfiguration projConfig)
        {
            this.Context.PreBuildTask(projConfig.ProjectAlias);

            this.Context.PreBuildTask("DotNetCoreRestore", false, projConfig.ProjectAlias)
            .Does(() =>
            {
                var restoreSettings = new DotNetCoreRestoreSettings
                {
                    Sources = this._helperSettings.DotNetCoreSettings.NugetSettings.GetFeedUrls().ToList()
                };

                this.Context.DotNetCoreRestore(projConfig.GetRelativeSlnFilePath().FullPath, restoreSettings);
            });
        }
        private void RegisterCleanTasks(IProjectConfiguration projConfig)
        {
            this.Context.BuildCleanTask(projConfig.ProjectAlias);

            this.Context.BuildCleanTask("DotNetCoreClean", false, projConfig.ProjectAlias)
            .Does(() =>
            {
                var clnSettings = new DotNetCoreCleanSettings
                {
                    Configuration = projConfig.Configuration,
                    Framework     = projConfig.Framework
                };

                this.Context.DotNetCoreClean(projConfig.GetRelativeSlnFilePath().FullPath, clnSettings);
            });

            this.Context.BuildCleanTask("BinAndObj", false, projConfig.ProjectAlias)
            .Does(() =>
            {
                var paths = projConfig.GetAllProjectOutputDirectoryPaths();
                foreach (var path in paths)
                {
                    this.Context.Debug($"Cleaning Directory: {path}");
                    this.Context.CleanDirectories(path);
                }
            });

            this.Context.BuildCleanTask("BuildTemp", false, projConfig.ProjectAlias)
            .Does(() =>
            {
                var buildTempDir = projConfig.BuildTempDirectory;
                if (buildTempDir != null && this.Context.DirectoryExists(buildTempDir))
                {
                    this.Context.Debug($"Deleting BuildTemp directory: {buildTempDir.FullPath}");
                    this.Context.DeleteDirectory(buildTempDir, true);
                }
            });
        }