Adding support for --serviceable option to pack command which puts <serviceable>true</serviceable> into the output nuspec
This commit is contained in:
parent
beb37128d8
commit
b596122d5c
10 changed files with 37 additions and 2 deletions
|
@ -68,6 +68,8 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
|
|
||||||
public PackOptions PackOptions { get; set; }
|
public PackOptions PackOptions { get; set; }
|
||||||
|
|
||||||
|
public bool Serviceable { get; set; }
|
||||||
|
|
||||||
public RuntimeOptions RuntimeOptions { get; set; }
|
public RuntimeOptions RuntimeOptions { get; set; }
|
||||||
|
|
||||||
public IDictionary<string, string> Commands { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
public IDictionary<string, string> Commands { get; } = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
|
@ -109,6 +109,7 @@ namespace NuGet
|
||||||
metadata.Authors = copy.Authors.Distinct();
|
metadata.Authors = copy.Authors.Distinct();
|
||||||
metadata.Owners = copy.Owners.Distinct();
|
metadata.Owners = copy.Owners.Distinct();
|
||||||
metadata.Tags = string.Join(",", copy.Tags).Trim();
|
metadata.Tags = string.Join(",", copy.Tags).Trim();
|
||||||
|
metadata.Serviceable = copy.Serviceable;
|
||||||
metadata.LicenseUrl = copy.LicenseUrl;
|
metadata.LicenseUrl = copy.LicenseUrl;
|
||||||
metadata.ProjectUrl = copy.ProjectUrl;
|
metadata.ProjectUrl = copy.ProjectUrl;
|
||||||
metadata.IconUrl = copy.IconUrl;
|
metadata.IconUrl = copy.IconUrl;
|
||||||
|
|
|
@ -77,6 +77,8 @@ namespace NuGet
|
||||||
|
|
||||||
public string Tags { get; set; }
|
public string Tags { get; set; }
|
||||||
|
|
||||||
|
public bool Serviceable { get; set; }
|
||||||
|
|
||||||
public IEnumerable<PackageDependencySet> DependencySets { get; set; } = new List<PackageDependencySet>();
|
public IEnumerable<PackageDependencySet> DependencySets { get; set; } = new List<PackageDependencySet>();
|
||||||
|
|
||||||
public ICollection<PackageReferenceSet> PackageAssemblyReferences { get; set; } = new List<PackageReferenceSet>();
|
public ICollection<PackageReferenceSet> PackageAssemblyReferences { get; set; } = new List<PackageReferenceSet>();
|
||||||
|
|
|
@ -130,6 +130,9 @@ namespace NuGet
|
||||||
case "tags":
|
case "tags":
|
||||||
manifestMetadata.Tags = value;
|
manifestMetadata.Tags = value;
|
||||||
break;
|
break;
|
||||||
|
case "serviceable":
|
||||||
|
manifestMetadata.Serviceable = XmlConvert.ToBoolean(value);
|
||||||
|
break;
|
||||||
case "dependencies":
|
case "dependencies":
|
||||||
manifestMetadata.DependencySets = ReadDependencySets(element);
|
manifestMetadata.DependencySets = ReadDependencySets(element);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -41,13 +41,19 @@ namespace NuGet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal const string SchemaVersionV6 = "http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd";
|
internal const string SchemaVersionV6 = "http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Added serviceble element under metadata.
|
||||||
|
/// </summary>
|
||||||
|
internal const string SchemaVersionV7 = "http://schemas.microsoft.com/packaging/2016/06/nuspec.xsd";
|
||||||
|
|
||||||
private static readonly string[] VersionToSchemaMappings = new[] {
|
private static readonly string[] VersionToSchemaMappings = new[] {
|
||||||
SchemaVersionV1,
|
SchemaVersionV1,
|
||||||
SchemaVersionV2,
|
SchemaVersionV2,
|
||||||
SchemaVersionV3,
|
SchemaVersionV3,
|
||||||
SchemaVersionV4,
|
SchemaVersionV4,
|
||||||
SchemaVersionV5,
|
SchemaVersionV5,
|
||||||
SchemaVersionV6
|
SchemaVersionV6,
|
||||||
|
SchemaVersionV7
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int GetVersionFromNamespace(string @namespace)
|
public static int GetVersionFromNamespace(string @namespace)
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace NuGet
|
||||||
public const int TargetFrameworkSupportForDependencyContentsAndToolsVersion = 4;
|
public const int TargetFrameworkSupportForDependencyContentsAndToolsVersion = 4;
|
||||||
public const int TargetFrameworkSupportForReferencesVersion = 5;
|
public const int TargetFrameworkSupportForReferencesVersion = 5;
|
||||||
public const int XdtTransformationVersion = 6;
|
public const int XdtTransformationVersion = 6;
|
||||||
|
public const int ServiceableVersion = 7;
|
||||||
|
|
||||||
public static int GetManifestVersion(ManifestMetadata metadata)
|
public static int GetManifestVersion(ManifestMetadata metadata)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +24,12 @@ namespace NuGet
|
||||||
|
|
||||||
private static int GetMaxVersionFromMetadata(ManifestMetadata metadata)
|
private static int GetMaxVersionFromMetadata(ManifestMetadata metadata)
|
||||||
{
|
{
|
||||||
// Important: check for version 5 before version 4
|
// Important: always add newer version checks at the top
|
||||||
|
if (metadata.Serviceable)
|
||||||
|
{
|
||||||
|
return ServiceableVersion;
|
||||||
|
}
|
||||||
|
|
||||||
bool referencesHasTargetFramework =
|
bool referencesHasTargetFramework =
|
||||||
metadata.PackageAssemblyReferences != null &&
|
metadata.PackageAssemblyReferences != null &&
|
||||||
metadata.PackageAssemblyReferences.Any(r => r.TargetFramework != null);
|
metadata.PackageAssemblyReferences.Any(r => r.TargetFramework != null);
|
||||||
|
|
|
@ -87,6 +87,12 @@ namespace NuGet
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Serviceable
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DevelopmentDependency
|
public bool DevelopmentDependency
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -284,6 +290,7 @@ namespace NuGet
|
||||||
ProjectUrl = manifestMetadata.ProjectUrl;
|
ProjectUrl = manifestMetadata.ProjectUrl;
|
||||||
RequireLicenseAcceptance = manifestMetadata.RequireLicenseAcceptance;
|
RequireLicenseAcceptance = manifestMetadata.RequireLicenseAcceptance;
|
||||||
DevelopmentDependency = manifestMetadata.DevelopmentDependency;
|
DevelopmentDependency = manifestMetadata.DevelopmentDependency;
|
||||||
|
Serviceable = manifestMetadata.Serviceable;
|
||||||
Description = manifestMetadata.Description;
|
Description = manifestMetadata.Description;
|
||||||
Summary = manifestMetadata.Summary;
|
Summary = manifestMetadata.Summary;
|
||||||
ReleaseNotes = manifestMetadata.ReleaseNotes;
|
ReleaseNotes = manifestMetadata.ReleaseNotes;
|
||||||
|
|
|
@ -51,6 +51,10 @@ namespace NuGet
|
||||||
AddElementIfNotNull(elem, ns, "copyright", metadata.Copyright);
|
AddElementIfNotNull(elem, ns, "copyright", metadata.Copyright);
|
||||||
AddElementIfNotNull(elem, ns, "language", metadata.Language);
|
AddElementIfNotNull(elem, ns, "language", metadata.Language);
|
||||||
AddElementIfNotNull(elem, ns, "tags", metadata.Tags);
|
AddElementIfNotNull(elem, ns, "tags", metadata.Tags);
|
||||||
|
if (metadata.Serviceable)
|
||||||
|
{
|
||||||
|
elem.Add(new XElement(ns + "serviceable", metadata.Serviceable));
|
||||||
|
}
|
||||||
|
|
||||||
elem.Add(GetXElementFromGroupableItemSets(
|
elem.Add(GetXElementFromGroupableItemSets(
|
||||||
ns,
|
ns,
|
||||||
|
|
|
@ -390,6 +390,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
builder.ReleaseNotes = project.PackOptions.ReleaseNotes;
|
builder.ReleaseNotes = project.PackOptions.ReleaseNotes;
|
||||||
builder.Language = project.Language;
|
builder.Language = project.Language;
|
||||||
builder.Tags.AddRange(project.PackOptions.Tags);
|
builder.Tags.AddRange(project.PackOptions.Tags);
|
||||||
|
builder.Serviceable = project.Serviceable;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(project.PackOptions.IconUrl))
|
if (!string.IsNullOrEmpty(project.PackOptions.IconUrl))
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
var buildBasePath = app.Option("-b|--build-base-path <OUTPUT_DIR>", "Directory in which to place temporary build outputs", CommandOptionType.SingleValue);
|
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 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 versionSuffix = app.Option("--version-suffix <VERSION_SUFFIX>", "Defines what `*` should be replaced with in version field in project.json", CommandOptionType.SingleValue);
|
||||||
|
var serviceable = app.Option("-s|--serviceable", "Set the serviceable flag in the output nuspec", CommandOptionType.NoValue);
|
||||||
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");
|
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(() =>
|
app.OnExecute(() =>
|
||||||
|
@ -64,6 +65,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
var artifactPathsCalculator = new ArtifactPathsCalculator(project, buildBasePathValue, outputValue, configValue);
|
var artifactPathsCalculator = new ArtifactPathsCalculator(project, buildBasePathValue, outputValue, configValue);
|
||||||
var packageBuilder = new PackagesGenerator(contexts, artifactPathsCalculator, configValue);
|
var packageBuilder = new PackagesGenerator(contexts, artifactPathsCalculator, configValue);
|
||||||
|
|
||||||
|
project.Serviceable = serviceable.HasValue();
|
||||||
|
|
||||||
int buildResult = 0;
|
int buildResult = 0;
|
||||||
if (!noBuild.HasValue())
|
if (!noBuild.HasValue())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue