Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
fix #2390 by using normalized version numbers during dnu publish
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Aug 28, 2015
1 parent 50aaca4 commit a297f5f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Microsoft.Dnx.Tooling/Building/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ private static string Normalize(string projectDir)

private static string GetPackagePath(Runtime.Project project, string outputPath, bool symbols = false)
{
string fileName = project.Name + "." + project.Version + (symbols ? ".symbols" : "") + ".nupkg";
string fileName = project.Name + "." + project.Version.GetNormalizedVersionString() + (symbols ? ".symbols" : "") + ".nupkg";
return Path.Combine(outputPath, fileName);
}

Expand Down
61 changes: 61 additions & 0 deletions test/Microsoft.Dnx.Tooling.FunctionalTests/DnuPublishTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,67 @@ public void DnuPublishConsoleApp(string flavor, string os, string architecture)
}
}

[Theory]
[MemberData(nameof(RuntimeComponents))]
public void DnuPublishConsoleAppWithNoSourceOptionNormalizesVersionNumber(string flavor, string os, string architecture)
{
var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

var projectStructure = @"{
'.': ['project.json', 'Config.json', 'Program.cs'],
'packages': {}
}";
var expectedOutputStructure = @"{
'approot': {
'global.json': '',
'packages': {
'PROJECT_NAME': {
'1.0.0': {
'.': ['PROJECT_NAME.1.0.0.nupkg', 'PROJECT_NAME.1.0.0.nupkg.sha512', 'PROJECT_NAME.nuspec'],
'root': {
'.': ['Config.json', 'project.json', 'project.lock.json']
},
'lib': {
'dnx451': ['PROJECT_NAME.dll', 'PROJECT_NAME.xml']
}
}
}
}
}
}".Replace("PROJECT_NAME", _projectName);

using (var testEnv = new DnuTestEnvironment(runtimeHomeDir, _projectName, _outputDirName))
{
DirTree.CreateFromJson(projectStructure)
.WithFileContents("project.json", @"{
""version"": ""1.0.0.0"",
""frameworks"": {
""dnx451"": {}
}
}")
.WriteTo(testEnv.ProjectPath);

var exitCode = DnuTestUtils.ExecDnu(
runtimeHomeDir,
subcommand: "restore",
arguments: "",
workingDir: testEnv.ProjectPath);
Assert.Equal(0, exitCode);

exitCode = DnuTestUtils.ExecDnu(
runtimeHomeDir,
subcommand: "publish",
arguments: string.Format("--no-source --out {0}",
testEnv.PublishOutputDirPath),
workingDir: testEnv.ProjectPath);
Assert.Equal(0, exitCode);

var expectedOutputDir = DirTree.CreateFromJson(expectedOutputStructure);
Assert.True(expectedOutputDir.MatchDirectoryOnDisk(testEnv.PublishOutputDirPath,
compareFileContents: false));
}
}

[Theory]
[MemberData(nameof(RuntimeComponents))]
public void DnuPublishCopiesAllProjectsToOneSrcFolder(string flavor, string os, string architecture)
Expand Down

0 comments on commit a297f5f

Please sign in to comment.