From 1e360a5346d3b83dc07a17930a0115710f60d641 Mon Sep 17 00:00:00 2001 From: Thomas Bolon Date: Tue, 9 Apr 2019 17:18:00 +0200 Subject: [PATCH] prototype --- .../NuGet.Build.Tasks.Pack.targets | 5 +++-- .../NuGet.Build.Tasks.Pack/PackTaskLogic.cs | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets b/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets index f83333e58ef..f7f6d0fae11 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/NuGet.Build.Tasks.Pack.targets @@ -318,8 +318,9 @@ Copyright (c) .NET Foundation. All rights reserved. Returns="@(_ProjectPathWithVersion)"> <_ProjectPathWithVersion Include="$(MSBuildProjectFullPath)"> - $(PackageVersion) - 1.0.0 + $(PackageDependencyVersion) + $(PackageVersion) + 1.0.0 diff --git a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs index 3857ede28b3..232bb18c340 100644 --- a/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs +++ b/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs @@ -803,13 +803,20 @@ private static void InitializeProjectDependencies( continue; } - var versionToUse = targetLibrary.Version; + var rangeToUse = new VersionRange(targetLibrary.Version); // Use the project reference version obtained at build time if it exists, otherwise fallback to the one in assets file. if (projectRefToVersionMap.TryGetValue(projectReference.ProjectPath, out var projectRefVersion)) { - versionToUse = NuGetVersion.Parse(projectRefVersion); + // First we try to use the projectRefVersion as a Version Range, to allow the referenced project to define the entire range + if (!VersionRange.TryParse(projectRefVersion, out rangeToUse)) + { + // Else, we fallback to parsing the range as a simplier version the creating a default range "[x,)" + var versionToUse = NuGetVersion.Parse(projectRefVersion); + rangeToUse = new VersionRange(versionToUse); + } } + // TODO: Implement false // https://github.com/NuGet/Home/issues/3891 // @@ -818,7 +825,7 @@ private static void InitializeProjectDependencies( { LibraryRange = new LibraryRange( targetLibrary.Name, - new VersionRange(versionToUse), + rangeToUse, LibraryDependencyTarget.All), IncludeType = projectReference.IncludeAssets & ~projectReference.ExcludeAssets, SuppressParent = projectReference.PrivateAssets