Skip to content

Commit

Permalink
Fix failing test due to nuget package path casing
Browse files Browse the repository at this point in the history
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 NuGet#151 and NuGet#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.
  • Loading branch information
kzu committed Dec 1, 2017
1 parent 9efe039 commit b6accef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
<PropertyGroup>
<_PrivateAssets>@(_PrimaryPackageReference -> '%(PrivateAssets)')</_PrivateAssets>
<_ShouldIncludeAssetsRegex>$(_NuGetPackageId)\\.+\\$(_PrivateAssets)\\.*</_ShouldIncludeAssetsRegex>
</PropertyGroup>

<ItemGroup Condition="'$(_PrivateAssets)' == 'all'">
Expand All @@ -191,7 +192,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- In this case, we only add files that have a matching path to the private assets value.
i.e. for Mono.Options, PrivateAssets=lib, we'll include the file if its full path contains
'Mono.Options\*\lib\*', meaning the file is a lib. -->
<_InferredPackageFile Include="@(_PrimaryOutputRelatedFile)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_PrimaryOutputRelatedFile.FullPath)', '$(_NuGetPackageId)\\.+\\$(_PrivateAssets)\\.*')) == 'true'">
<_InferredPackageFile Include="@(_PrimaryOutputRelatedFile)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(_PrimaryOutputRelatedFile.FullPath)', '$(_ShouldIncludeAssetsRegex)', 'RegexOptions.IgnoreCase')) == 'true'">
<Kind>$(PrimaryOutputKind)</Kind>
<FrameworkSpecific>$(PrimaryOutputFrameworkSpecific)</FrameworkSpecific>
</_InferredPackageFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Options">
<Version>*</Version>
<Version>5.3.0</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>*</Version>
<Version>9.0.1</Version>
<PrivateAssets>lib</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit">
<Version>*</Version>
<Version>2.3.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Scenario.targets))\Scenario.targets" />
Expand Down

0 comments on commit b6accef

Please sign in to comment.