Exemplo n.º 1
0
        protected virtual void ProcessContext(ProjectContext context)
        {
            PopulateDependencies(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
            var outputName  = GetProjectOutputName(context.TargetFramework);

            var resourceCultures = context.ProjectFile.Files.ResourceFiles
                                   .Select(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
                                   .Distinct();

            foreach (var culture in resourceCultures)
            {
                if (string.IsNullOrEmpty(culture))
                {
                    continue;
                }

                var resourceFilePath = Path.Combine(culture, $"{Project.Name}.resources.dll");
                TryAddOutputFile(context, inputFolder, resourceFilePath);
            }

            TryAddOutputFile(context, inputFolder, outputName);
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.xml");
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.runtimeconfig.json");
        }
Exemplo n.º 2
0
        protected override void ProcessContext(ProjectContext context)
        {
            base.ProcessContext(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);

            TryAddOutputFile(context, inputFolder, $"{Project.Name}.pdb");
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.mdb");
        }
Exemplo n.º 3
0
        protected override void ProcessContext(ProjectContext context)
        {
            base.ProcessContext(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
            var ouptutName  = Project.GetCompilerOptions(context.TargetFramework, Configuration).OutputName;

            TryAddOutputFile(context, inputFolder, $"{ouptutName}.pdb");
            TryAddOutputFile(context, inputFolder, $"{ouptutName}.mdb");
        }
Exemplo n.º 4
0
        protected virtual void ProcessContext(ProjectContext context)
        {
            PopulateDependencies(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);

            var compilerOptions = Project.GetCompilerOptions(context.TargetFramework, Configuration);
            var outputName      = compilerOptions.OutputName;
            var outputExtension =
                context.TargetFramework.IsDesktop() && compilerOptions.EmitEntryPoint.GetValueOrDefault()
                    ? ".exe" : ".dll";

            IEnumerable <string> resourceCultures = null;

            if (compilerOptions.EmbedInclude == null)
            {
                resourceCultures = context.ProjectFile.Files.ResourceFiles
                                   .Select(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
                                   .Distinct();
            }
            else
            {
                var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.EmbedInclude, "/", diagnostics: null);
                resourceCultures = includeFiles
                                   .Select(file => ResourceUtility.GetResourceCultureName(file.SourcePath))
                                   .Distinct();
            }

            foreach (var culture in resourceCultures)
            {
                if (string.IsNullOrEmpty(culture))
                {
                    continue;
                }

                var resourceFilePath = Path.Combine(culture, $"{outputName}.resources.dll");
                TryAddOutputFile(context, inputFolder, resourceFilePath);
            }

            TryAddOutputFile(context, inputFolder, outputName + outputExtension);
            TryAddOutputFile(context, inputFolder, $"{outputName}.xml");
            TryAddOutputFile(context, inputFolder, $"{outputName}.runtimeconfig.json");
        }
Exemplo n.º 5
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           = ProjectReaderSettings.ReadFromEnvironment();
                var versionSuffixValue = versionSuffix.Value();

                if (!string.IsNullOrEmpty(versionSuffixValue))
                {
                    settings.VersionSuffix = versionSuffixValue;
                }

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

                var contexts = ProjectContext.CreateContextForEachFramework(pathValue, settings);
                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, versionSuffixValue);
                    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);
            }
        }
Exemplo n.º 6
0
 public PackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
 {
     ArtifactPathsCalculator = artifactPathsCalculator;
     Project       = project;
     Configuration = configuration;
 }
Exemplo n.º 7
0
 public SymbolPackageGenerator(Project project, string configuration, ArtifactPathsCalculator artifactPathsCalculator)
     : base(project, configuration, artifactPathsCalculator)
 {
 }