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

Commit

Permalink
Fixed nuget version casing mismatch
Browse files Browse the repository at this point in the history
- Always update the nuspec with the resolved version and id on
install.

#2970
  • Loading branch information
davidfowl committed Oct 13, 2015
1 parent 82ee48c commit ca79ade
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
4 changes: 4 additions & 0 deletions misc/MismatchedVersionCasing/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"projects": [ "src" ],
"packages": "packages"
}
8 changes: 8 additions & 0 deletions misc/MismatchedVersionCasing/src/A/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"frameworks": {
"dnx451": { }
},
"dependencies": {
"Contentful.NET": "0.0.5-Alpha"
}
}
30 changes: 14 additions & 16 deletions src/Microsoft.Dnx.Tooling/Utils/NuGetPackageUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,21 @@ await ConcurrencyUtilities.ExecuteWithFileLocked(targetNupkg, action: async _ =>
// Fixup the casing of the nuspec on disk to match what we expect
var nuspecFile = Directory.EnumerateFiles(targetPath, "*" + NuGet.Constants.ManifestExtension).Single();
if (!string.Equals(nuspecFile, targetNuspec, StringComparison.Ordinal))
Manifest manifest = null;
using (var nuspecStream = File.OpenRead(nuspecFile))
{
Manifest manifest = null;
using (var nuspecStream = File.OpenRead(nuspecFile))
{
manifest = Manifest.ReadFrom(nuspecStream, validateSchema: false);
manifest.Metadata.Id = library.Name;
}
// Delete the previous nuspec file
File.Delete(nuspecFile);
// Write the new manifest
using (var targetNuspecStream = File.OpenWrite(targetNuspec))
{
manifest.Save(targetNuspecStream);
}
manifest = Manifest.ReadFrom(nuspecStream, validateSchema: false);
manifest.Metadata.Id = library.Name;
manifest.Metadata.Version = library.Version;
}
// Delete the previous nuspec file
File.Delete(nuspecFile);
// Write the new manifest
using (var targetNuspecStream = File.OpenWrite(targetNuspec))
{
manifest.Save(targetNuspecStream);
}
// Note: PackageRepository relies on the hash file being written out as the final operation as part of a package install
Expand Down
11 changes: 11 additions & 0 deletions test/Microsoft.Dnx.Tooling.FunctionalTests/DnuRestoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,16 @@ public void Restore_DoNotRestoreNestProjects(DnxSdk sdk)
Assert.Equal(1, lockFiles.Length);
Assert.Equal("Main", Path.GetFileName(Path.GetDirectoryName(lockFiles[0])));
}

[Theory, TraceTest]
[MemberData(nameof(DnxSdks))]
public void Restore_NormalizesVersionCasing(DnxSdk sdk)
{
var solution = TestUtils.GetSolution<DnuRestoreTests>(sdk, "MismatchedVersionCasing");

var result = sdk.Dnu.Restore(solution.GetProject("A"));

Assert.Equal(0, result.ExitCode);
}
}
}

0 comments on commit ca79ade

Please sign in to comment.