/// <summary> /// <p>The <c>dotnet pack</c> command builds the project and creates NuGet packages. The result of this command is a NuGet package. If the <c>--include-symbols</c> option is present, another package containing the debug symbols is created.</p><p>NuGet dependencies of the packed project are added to the <em>.nuspec</em> file, so they're properly resolved when the package is installed. Project-to-project references aren't packaged inside the project. Currently, you must have a package per project if you have project-to-project dependencies.</p><p>By default, <c>dotnet pack</c> builds the project first. If you wish to avoid this behavior, pass the <c>--no-build</c> option. This is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built.</p><p>You can provide MSBuild properties to the <c>dotnet pack</c> command for the packing process. For more information, see <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/csproj#nuget-metadata-properties">NuGet metadata properties</a> and the <a href="https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference">MSBuild Command-Line Reference</a>.</p> /// <p>For more details, visit the <a href="https://docs.microsoft.com/en-us/dotnet/core/tools/">official website</a>.</p> /// </summary> /// <remarks> /// <p>This is a <a href="http://www.nuke.build/docs/authoring-builds/cli-tools.html#fluent-apis">CLI wrapper with fluent API</a> that allows to modify the following arguments:</p> /// <ul> /// <li><c><project></c> via <see cref="DotNetPackSettings.Project"/></li> /// <li><c>--configuration</c> via <see cref="DotNetPackSettings.Configuration"/></li> /// <li><c>--disable-parallel</c> via <see cref="DotNetPackSettings.DisableParallel"/></li> /// <li><c>--force</c> via <see cref="DotNetPackSettings.Force"/></li> /// <li><c>--force-evaluate</c> via <see cref="DotNetPackSettings.ForceEvaluate"/></li> /// <li><c>--ignore-failed-sources</c> via <see cref="DotNetPackSettings.IgnoreFailedSources"/></li> /// <li><c>--include-source</c> via <see cref="DotNetPackSettings.IncludeSource"/></li> /// <li><c>--include-symbols</c> via <see cref="DotNetPackSettings.IncludeSymbols"/></li> /// <li><c>--lock-file-path</c> via <see cref="DotNetPackSettings.LockFilePath"/></li> /// <li><c>--locked-mode</c> via <see cref="DotNetPackSettings.LockedMode"/></li> /// <li><c>--no-build</c> via <see cref="DotNetPackSettings.NoBuild"/></li> /// <li><c>--no-cache</c> via <see cref="DotNetPackSettings.NoCache"/></li> /// <li><c>--no-dependencies</c> via <see cref="DotNetPackSettings.NoDependencies"/></li> /// <li><c>--no-restore</c> via <see cref="DotNetPackSettings.NoRestore"/></li> /// <li><c>--nologo</c> via <see cref="DotNetPackSettings.NoLogo"/></li> /// <li><c>--output</c> via <see cref="DotNetPackSettings.OutputDirectory"/></li> /// <li><c>--packages</c> via <see cref="DotNetPackSettings.PackageDirectory"/></li> /// <li><c>--runtime</c> via <see cref="DotNetPackSettings.Runtime"/></li> /// <li><c>--serviceable</c> via <see cref="DotNetPackSettings.Serviceable"/></li> /// <li><c>--source</c> via <see cref="DotNetPackSettings.Sources"/></li> /// <li><c>--use-lock-file</c> via <see cref="DotNetPackSettings.UseLockFile"/></li> /// <li><c>--verbosity</c> via <see cref="DotNetPackSettings.Verbosity"/></li> /// <li><c>--version-suffix</c> via <see cref="DotNetPackSettings.VersionSuffix"/></li> /// <li><c>/property</c> via <see cref="DotNetPackSettings.Properties"/></li> /// </ul> /// </remarks> private (BlockingCollection <ILineOut>, int) DotNetPack(DotNetPackSettings toolSettings = null) { toolSettings = toolSettings ?? new DotNetPackSettings(); ProcessStartInfo processStartInfo = SlugCmdProcess.GetDefaultProcessSettings(); ToolSettingsToProcessInfoConverter.Convert(toolSettings, processStartInfo); SlugCmdProcess slugCmdProcess = new SlugCmdProcess("Dot Net Pack", processStartInfo); slugCmdProcess.Execute(DotNetPack_OutputProcessor); return(slugCmdProcess.Output, slugCmdProcess.ExitCode); }
private static void PackageWithCli(BuildContext context) { var settings = new DotNetPackSettings { Configuration = context.MsBuildConfiguration, OutputDirectory = Paths.Nuget, MSBuildSettings = context.MsBuildSettings, }; // GitVersion.MsBuild, global tool & core context.DotNetPack("./src/GitVersion.Core", settings); settings.ArgumentCustomization = arg => arg.Append("/p:PackAsTool=true"); context.DotNetPack("./src/GitVersion.App", settings); settings.ArgumentCustomization = arg => arg.Append("/p:IsPackaging=true"); context.DotNetPack("./src/GitVersion.MsBuild", settings); }
private static void PackageWithCli(BuildContext context) { var settings = new DotNetPackSettings { Configuration = context.MsBuildConfiguration, OutputDirectory = Paths.Packages, MSBuildSettings = context.MsBuildSettings, }; string[] projectPaths = { "./src/Core/src/Servly.Core", "./src/Authentication/src/Servly.Authentication", "./src/Authentication/src/Servly.Authentication.AspNetCore", "./src/Idempotency/src/Servly.Idempotency.AspNetCore" }; foreach (string project in projectPaths) { context.DotNetPack(project, settings); } }
/// <inheritdoc /> public override void Run(BuildContext context) { context.Log.Information("Package version: " + context.BuildVersion); var packSettings = new DotNetPackSettings { Configuration = context.BuildConfiguration, NoBuild = false, NoRestore = true, OutputDirectory = "./artifacts/packages", IncludeSymbols = true, MSBuildSettings = new DotNetCoreMSBuildSettings().SetConfiguration(context.BuildConfiguration) .SetVersion(context.BuildVersion) }; context.DotNetPack("./src/simpleauth.shared/simpleauth.shared.csproj", packSettings); context.DotNetPack("./src/simpleauth/simpleauth.csproj", packSettings); context.DotNetPack("./src/simpleauth.client/simpleauth.client.csproj", packSettings); context.DotNetPack("./src/simpleauth.stores.marten/simpleauth.stores.marten.csproj", packSettings); context.DotNetPack("./src/simpleauth.stores.redis/simpleauth.stores.redis.csproj", packSettings); context.DotNetPack("./src/simpleauth.sms/simpleauth.sms.csproj", packSettings); context.DotNetPack("./src/simpleauth.ui/simpleauth.ui.csproj", packSettings); context.DotNetPack("./src/simpleauth.sms.ui/simpleauth.sms.ui.csproj", packSettings); }
/// <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); }