豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 76e8482

Browse files
committed
Fix failing test due to nuget package path casing
The package cache lower cases all paths, which no longer matches the package id as we were previously doing. We need to match in a case- insensitive way therefore for private assets matching to succeed. This fixes a broken unit test that was blocking two PRs #151 and #150. Also, fix the nuget package versions at the time of this test authoring, so we don't accidentally break if newer packages ever change and cause the expectations to fail.
1 parent 281b6e2 commit 76e8482

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Copyright (c) .NET Foundation. All rights reserved.
178178
</ItemGroup>
179179
<PropertyGroup>
180180
<_PrivateAssets>@(_PrimaryPackageReference -> '%(PrivateAssets)')</_PrivateAssets>
181+
<_ShouldIncludeAssetsRegex>$(_NuGetPackageId)\\.+\\$(_PrivateAssets)\\.*</_ShouldIncludeAssetsRegex>
181182
</PropertyGroup>
182183

183184
<ItemGroup Condition="'$(_PrivateAssets)' == 'all'">
@@ -191,7 +192,7 @@ Copyright (c) .NET Foundation. All rights reserved.
191192
<!-- In this case, we only add files that have a matching path to the private assets value.
192193
i.e. for Mono.Options, PrivateAssets=lib, we'll include the file if its full path contains
193194
'Mono.Options\*\lib\*', meaning the file is a lib. -->
194-
<_InferredPackageFile Include="@(_PrimaryOutputRelatedFile)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_PrimaryOutputRelatedFile.FullPath)', '$(_NuGetPackageId)\\.+\\$(_PrivateAssets)\\.*')) == 'true'">
195+
<_InferredPackageFile Include="@(_PrimaryOutputRelatedFile)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_PrimaryOutputRelatedFile.FullPath)', '$(_ShouldIncludeAssetsRegex)', 'RegexOptions.IgnoreCase')) == 'true'">
195196
<Kind>$(PrimaryOutputKind)</Kind>
196197
<FrameworkSpecific>$(PrimaryOutputFrameworkSpecific)</FrameworkSpecific>
197198
</_InferredPackageFile>

src/Build/NuGet.Build.Packaging.Tests/Scenarios/given_a_library_with_private_assets_reference/a.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="Mono.Options">
9-
<Version>*</Version>
9+
<Version>5.3.0</Version>
1010
<PrivateAssets>all</PrivateAssets>
1111
</PackageReference>
1212
<PackageReference Include="Newtonsoft.Json">
13-
<Version>*</Version>
13+
<Version>9.0.1</Version>
1414
<PrivateAssets>lib</PrivateAssets>
1515
</PackageReference>
1616
<PackageReference Include="xunit">
17-
<Version>*</Version>
17+
<Version>2.3.0</Version>
1818
</PackageReference>
1919
</ItemGroup>
2020
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Scenario.targets))\Scenario.targets" />

0 commit comments

Comments
 (0)