Ejemplo n.º 1
0
 public PackagesGenerator(
     IEnumerable<ProjectContext> contexts,
     ArtifactPathsCalculator artifactPathsCalculator,
     string configuration)
 {
     _contexts = contexts;
     _artifactPathsCalculator = artifactPathsCalculator;
     _configuration = configuration;
 }
Ejemplo n.º 2
0
 public PackagesGenerator(
     IEnumerable <ProjectContext> contexts,
     ArtifactPathsCalculator artifactPathsCalculator,
     string configuration)
 {
     _contexts = contexts;
     _artifactPathsCalculator = artifactPathsCalculator;
     _configuration           = configuration;
 }
Ejemplo n.º 3
0
 public BuildProjectCommand(
     Project project, 
     ArtifactPathsCalculator artifactPathsCalculator, 
     string buildBasePath, 
     string configuration)
 {
     _project = project;
     _artifactPathsCalculator = artifactPathsCalculator;
     _buildBasePath = buildBasePath;
     _configuration = configuration;
 }
Ejemplo n.º 4
0
 public BuildProjectCommand(
     Project project,
     ArtifactPathsCalculator artifactPathsCalculator,
     string intermediateOutputPath,
     string configuration)
 {
     _project = project;
     _artifactPathsCalculator = artifactPathsCalculator;
     _intermediateOutputPath  = intermediateOutputPath;
     _configuration           = configuration;
 }
Ejemplo n.º 5
0
 public BuildProjectCommand(
     Project project, 
     ArtifactPathsCalculator artifactPathsCalculator, 
     string intermediateOutputPath, 
     string configuration)
 {
     _project = project;
     _artifactPathsCalculator = artifactPathsCalculator;
     _intermediateOutputPath = intermediateOutputPath;
     _configuration = configuration;
 }
Ejemplo n.º 6
0
 public BuildProjectCommand(
     Project project,
     ArtifactPathsCalculator artifactPathsCalculator,
     string buildBasePath,
     string configuration,
     string versionSuffix)
 {
     _project = project;
     _artifactPathsCalculator = artifactPathsCalculator;
     _buildBasePath           = buildBasePath;
     _configuration           = configuration;
     _versionSuffix           = versionSuffix;
 }
Ejemplo n.º 7
0
        public static int Run(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            var app = new CommandLineApplication();
            app.Name = "dotnet pack";
            app.FullName = ".NET Packager";
            app.Description = "Packager for the .NET Platform";
            app.HelpOption("-h|--help");

            var output = app.Option("-o|--output <OUTPUT_DIR>", "Directory in which to place outputs", CommandOptionType.SingleValue);
            var noBuild = app.Option("--no-build", "Do not build project before packing", CommandOptionType.NoValue);
            var buildBasePath = app.Option("-b|--build-base-path <OUTPUT_DIR>", "Directory in which to place temporary build outputs", CommandOptionType.SingleValue);
            var configuration = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
            var versionSuffix = app.Option("--version-suffix <VERSION_SUFFIX>", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue);
            var path = app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");

            app.OnExecute(() =>
            {
                // Locate the project and get the name and full path
                var pathValue = path.Value;
                if (string.IsNullOrEmpty(pathValue))
                {
                    pathValue = Directory.GetCurrentDirectory();
                }

                if(!pathValue.EndsWith(Project.FileName))
                {
                    pathValue = Path.Combine(pathValue, Project.FileName);
                }

                if(!File.Exists(pathValue))
                {
                    Reporter.Error.WriteLine($"Unable to find a project.json in {pathValue}");
                    return 1;
                }

                // Set defaults based on the environment
                var settings = new ProjectReaderSettings();
                settings.VersionSuffix = Environment.GetEnvironmentVariable("DOTNET_BUILD_VERSION");
                settings.AssemblyFileVersion = Environment.GetEnvironmentVariable("DOTNET_ASSEMBLY_FILE_VERSION");

                if (versionSuffix.HasValue())
                {
                    settings.VersionSuffix = versionSuffix.Value();
                }

                var contexts = ProjectContext.CreateContextForEachFramework(pathValue, settings);

                var configValue = configuration.Value() ?? Cli.Utils.Constants.DefaultConfiguration;
                var outputValue = output.Value();
                var buildBasePathValue = buildBasePath.Value();

                var project = contexts.First().ProjectFile;

                var artifactPathsCalculator = new ArtifactPathsCalculator(project, buildBasePathValue, outputValue, configValue);
                var packageBuilder = new PackagesGenerator(contexts, artifactPathsCalculator, configValue);

                int buildResult = 0;
                if (!noBuild.HasValue())
                {
                    var buildProjectCommand = new BuildProjectCommand(project, artifactPathsCalculator, buildBasePathValue, configValue);
                    buildResult = buildProjectCommand.Execute();
                }

                return buildResult != 0 ? buildResult : packageBuilder.Build();
            });

            try
            {
                return app.Execute(args);
            }
            catch (Exception ex)
            {
#if DEBUG
                Console.Error.WriteLine(ex);
#else
                Console.Error.WriteLine(ex.Message);
#endif
                return 1;
            }
        }                
Ejemplo n.º 8
0
 public SymbolPackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
     : base(project, configuration, artifactPathsCalculator)
 {
 }
Ejemplo n.º 9
0
 public PackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
 {
     ArtifactPathsCalculator = artifactPathsCalculator;
     Project = project;
     Configuration = configuration;
 }