Skip to content

Commit

Permalink
prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
tbolon committed Apr 9, 2019
1 parent face61a commit 1e360a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,9 @@ Copyright (c) .NET Foundation. All rights reserved.
Returns="@(_ProjectPathWithVersion)">
<ItemGroup>
<_ProjectPathWithVersion Include="$(MSBuildProjectFullPath)">
<ProjectVersion Condition="'$(PackageVersion)' != ''">$(PackageVersion)</ProjectVersion>
<ProjectVersion Condition="'$(PackageVersion)' == ''">1.0.0</ProjectVersion>
<ProjectVersion Condition="'$(ProjectVersion)' == ''">$(PackageDependencyVersion)</ProjectVersion>
<ProjectVersion Condition="'$(ProjectVersion)' == ''">$(PackageVersion)</ProjectVersion>
<ProjectVersion Condition="'$(ProjectVersion)' == ''">1.0.0</ProjectVersion>
</_ProjectPathWithVersion>
</ItemGroup>
</Target>
Expand Down
13 changes: 10 additions & 3 deletions src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TreatAsPackageReference>false</TreatAsPackageReference>
// https://github.com/NuGet/Home/issues/3891
//
Expand All @@ -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
Expand Down

0 comments on commit 1e360a5

Please sign in to comment.