Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 9441713

Browse files
committed
When inferring @content/@none with copy to output, use full path
When doing P2P references, not using the full path causes the resulting package to fail since the path is relative to the referenced project, rather than the referencing one.
1 parent aa80181 commit 9441713

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/Build/NuGet.Build.Packaging.Tasks/NuGet.Build.Packaging.Inference.targets

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Copyright (c) .NET Foundation. All rights reserved.
3232

3333
<!-- Only default to true if the project isn't a nuget packaging project itself and its primary output is lib. -->
3434
<IncludeFrameworkReferencesInPackage Condition="'$(IncludeFrameworkReferencesInPackage)' == '' and '$(IsPackagingProject)' != 'true' and '$(PrimaryOutputKind)' == 'Lib'">true</IncludeFrameworkReferencesInPackage>
35+
36+
<_OutputFullPath Condition="$([System.IO.Path]::IsPathRooted($(OutputPath)))">$(OutputPath)</_OutputFullPath>
37+
<_OutputFullPath Condition="'$(_OutputFullPath)' == ''">$(MSBuildProjectDirectory)\$(OutputPath)</_OutputFullPath>
3538
</PropertyGroup>
3639

3740
<PropertyGroup>
@@ -106,7 +109,7 @@ Copyright (c) .NET Foundation. All rights reserved.
106109

107110
<!-- NOTE: Content is opt-out (must have Pack=false to exclude if IncludeContentInPackage=true) -->
108111
<!-- Stuff that is copied to output should be included from that output location -->
109-
<_InferredPackageFile Include="@(_ContentToInfer->'$(OutputPath)%(TargetPath)')"
112+
<_InferredPackageFile Include="@(_ContentToInfer->'$(_OutputFullPath)\%(TargetPath)')"
110113
Condition="'%(_ContentToInfer.CopyToOutputDirectory)' != '' and '%(_ContentToInfer.CopyToOutputDirectory)' != 'Never'">
111114
<Kind Condition="'%(_ContentToInfer.Kind)' == ''">$(PrimaryOutputKind)</Kind>
112115
</_InferredPackageFile>
@@ -118,7 +121,7 @@ Copyright (c) .NET Foundation. All rights reserved.
118121

119122
<!-- NOTE: None is also opt-out (must have Pack=false to exclude if IncludeNoneInPackage=true, but this property defaults to false) -->
120123
<!-- Likewise, include from target path if it's copied, from source path otherwise -->
121-
<_InferredPackageFile Include="@(_NoneToInfer->'$(OutputPath)%(TargetPath)')"
124+
<_InferredPackageFile Include="@(_NoneToInfer->'$(_OutputFullPath)\%(TargetPath)')"
122125
Condition="'%(_NoneToInfer.CopyToOutputDirectory)' != '' and '%(_NoneToInfer.CopyToOutputDirectory)' != 'Never'">
123126
<Kind Condition="'%(_NoneToInfer.Kind)' == ''">$(PrimaryOutputKind)</Kind>
124127
</_InferredPackageFile>

src/Build/NuGet.Build.Packaging.Tests/given_duplicate_package_files.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public void same_source_different_target_are_preserved()
5353
Assert.Equal(TargetResultCode.Success, result.ResultCode);
5454
}
5555

56-
5756
[Fact]
5857
public void real_duplicates_fail()
5958
{

0 commit comments

Comments
 (0)