Changing schema version to 8 to match NuGet internal value and adding a pack test for the --serviceable option.
This commit is contained in:
parent
b596122d5c
commit
e45259c6fa
4 changed files with 49 additions and 5 deletions
|
@ -44,7 +44,7 @@ namespace NuGet
|
|||
/// <summary>
|
||||
/// Added serviceble element under metadata.
|
||||
/// </summary>
|
||||
internal const string SchemaVersionV7 = "http://schemas.microsoft.com/packaging/2016/06/nuspec.xsd";
|
||||
internal const string SchemaVersionV8 = "http://schemas.microsoft.com/packaging/2016/06/nuspec.xsd";
|
||||
|
||||
private static readonly string[] VersionToSchemaMappings = new[] {
|
||||
SchemaVersionV1,
|
||||
|
@ -53,7 +53,7 @@ namespace NuGet
|
|||
SchemaVersionV4,
|
||||
SchemaVersionV5,
|
||||
SchemaVersionV6,
|
||||
SchemaVersionV7
|
||||
SchemaVersionV8
|
||||
};
|
||||
|
||||
public static int GetVersionFromNamespace(string @namespace)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace NuGet
|
|||
public const int TargetFrameworkSupportForDependencyContentsAndToolsVersion = 4;
|
||||
public const int TargetFrameworkSupportForReferencesVersion = 5;
|
||||
public const int XdtTransformationVersion = 6;
|
||||
public const int ServiceableVersion = 7;
|
||||
public const int ServiceableVersion = 8;
|
||||
|
||||
public static int GetManifestVersion(ManifestMetadata metadata)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
private string _tempOutputDirectory;
|
||||
private string _configuration;
|
||||
private string _versionSuffix;
|
||||
private string _serviceable;
|
||||
|
||||
private string OutputOption
|
||||
{
|
||||
|
@ -64,13 +65,24 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
}
|
||||
}
|
||||
|
||||
private string ServiceableOption
|
||||
{
|
||||
get
|
||||
{
|
||||
return _serviceable == string.Empty ?
|
||||
"" :
|
||||
$"--serviceable";
|
||||
}
|
||||
}
|
||||
|
||||
public PackCommand(
|
||||
string projectPath,
|
||||
string output = "",
|
||||
string buildBasePath = "",
|
||||
string tempOutput="",
|
||||
string configuration="",
|
||||
string versionSuffix="")
|
||||
string versionSuffix="",
|
||||
string serviceable = "")
|
||||
: base("dotnet")
|
||||
{
|
||||
_projectPath = projectPath;
|
||||
|
@ -79,6 +91,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
_tempOutputDirectory = tempOutput;
|
||||
_configuration = configuration;
|
||||
_versionSuffix = versionSuffix;
|
||||
_serviceable = serviceable;
|
||||
}
|
||||
|
||||
public override CommandResult Execute(string args = "")
|
||||
|
@ -89,7 +102,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
private string BuildArgs()
|
||||
{
|
||||
return $"{_projectPath} {OutputOption} {BuildBasePathOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption}";
|
||||
return $"{_projectPath} {OutputOption} {BuildBasePathOption} {TempOutputOption} {ConfigurationOption} {VersionSuffixOption} {ServiceableOption}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using FluentAssertions;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
|
@ -150,6 +152,35 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
|||
.Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HasServiceableFlagWhenArgumentPassed()
|
||||
{
|
||||
var root = Temp.CreateDirectory();
|
||||
|
||||
var testLibDir = root.CreateDirectory("TestLibrary");
|
||||
var sourceTestLibDir = Path.Combine(_testProjectsRoot, "TestLibraryWithConfiguration");
|
||||
|
||||
CopyProjectToTempDir(sourceTestLibDir, testLibDir);
|
||||
|
||||
var testProject = GetProjectPath(testLibDir);
|
||||
var packCommand = new PackCommand(testProject, configuration: "Debug", serviceable: "true");
|
||||
var result = packCommand.Execute();
|
||||
result.Should().Pass();
|
||||
|
||||
var outputDir = new DirectoryInfo(Path.Combine(testLibDir.Path, "bin", "Debug"));
|
||||
outputDir.Should().Exist();
|
||||
outputDir.Should().HaveFiles(new[] { "TestLibrary.1.0.0.nupkg", "TestLibrary.1.0.0.symbols.nupkg" });
|
||||
|
||||
var outputPackage = Path.Combine(outputDir.FullName, "TestLibrary.1.0.0.nupkg");
|
||||
var zip = ZipFile.Open(outputPackage, ZipArchiveMode.Read);
|
||||
zip.Entries.Should().Contain(e => e.FullName == "TestLibrary.nuspec");
|
||||
|
||||
var manifestReader = new StreamReader(zip.Entries.First(e => e.FullName == "TestLibrary.nuspec").Open());
|
||||
var nuspecXml = XDocument.Parse(manifestReader.ReadToEnd());
|
||||
var node = nuspecXml.Descendants().Single(e => e.Name.LocalName == "serviceable");
|
||||
Assert.Equal("true", node.Value);
|
||||
}
|
||||
|
||||
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
|
||||
{
|
||||
// copy all the files to temp dir
|
||||
|
|
Loading…
Reference in a new issue