Example #1
0
        /// <summary>
        /// Run Pack Process
        /// </summary>
        /// <returns></returns>
        protected override StageCompletionStatusEnum ExecuteProcess()
        {
            CISession.OutputDirectory.GlobFiles("*.nupkg", "*symbols.nupkg").ForEach(DeleteFile);

            DotNetPackSettings settings;

            foreach (SlugCIProject project in CISession.Projects)
            {
                AddOutputText("Project: " + project.Name, OutputType.Std);
                if (project.Deploy == SlugCIDeployMethod.Nuget || project.Deploy == SlugCIDeployMethod.Tool)
                {
                    AddOutputText("  --> Is Nuget Packable.", OutputType.Info);
                }
                else
                {
                    AddOutputText("  --> Is Not Nuget Packable.", OutputType.Info);
                }

                if (project.Deploy != SlugCIDeployMethod.Nuget && project.Deploy != SlugCIDeployMethod.Tool)
                {
                    continue;
                }
                settings = new DotNetPackSettings()
                {
                    Project            = project.VSProject.Path,
                    OutputDirectory    = CISession.OutputDirectory,
                    IncludeSymbols     = true,
                    NoRestore          = true,
                    Verbosity          = DotNetVerbosity.Minimal,
                    PropertiesInternal = new Dictionary <string, object>(),
                    NoBuild            = true,
                };

                settings = settings.SetFileVersion(CISession.VersionInfo.FileVersion)
                           .SetAssemblyVersion(CISession.VersionInfo.AssemblyVersion)
                           .SetConfiguration(CISession.CompileConfig)
                           .SetInformationalVersion(CISession.VersionInfo.InformationalVersion)
                           .SetVersion(CISession.VersionInfo.SemVersionAsString);

                // We might need to override package name if this is an alpha or beta build.
                if (project.Deploy == SlugCIDeployMethod.Tool)
                {
                    settings.SetPackageId(project.PackageId + "-" + CISession.PublishTarget.ToString());
                }


                (BlockingCollection <ILineOut> output, int exitCode) = DotNetPack(settings);
                StageOutput.AddRange(output);
                if (exitCode != 0)
                {
                    AOT_Error("DotNetPack returned non-zero exit code: " + exitCode);
                    project.Results.PackedSuccess = false;
                }
                else
                {
                    // See if successfully created package file
                    string searchName     = project.AssemblyName + "." + CISession.VersionInfo.SemVersionAsString + ".nupkg";
                    var    matchingvalues =
                        output.Where(outputVal => (outputVal.Text.Contains("Successfully created package") && (outputVal.Text.Contains(searchName))));
                    if (matchingvalues.Count() == 1)
                    {
                        project.Results.PackedSuccess = true;
                    }
                    else
                    {
                        project.Results.PackedSuccess = false;
                    }
                }

                // We set published to false here, as we can't really do it in the publish step
                project.Results.PublishedSuccess = false;
            }

            return(StageCompletionStatusEnum.Success);
        }