Fix package overrides (#21329)

* Fix package overrides

* Add a test
This commit is contained in:
John Luo 2020-04-30 13:59:32 -07:00 committed by GitHub
parent 63415b7dd2
commit 2fa0212285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 15 deletions

View File

@ -7,6 +7,10 @@
<PlatformManifestFileName>PlatformManifest.txt</PlatformManifestFileName>
<PlatformManifestOutputPath>$(ArtifactsObjDir)$(PlatformManifestFileName)</PlatformManifestOutputPath>
<DisablePubternalApiCheck>true</DisablePubternalApiCheck>
<!-- Platform manifest and package override metatdata -->
<ReferencePackSharedFxVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0</ReferencePackSharedFxVersion>
<ReferencePackSharedFxVersion Condition="'$(VersionSuffix)' != ''">$(ReferencePackSharedFxVersion)-$(VersionSuffix)</ReferencePackSharedFxVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -50,10 +50,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<FrameworkListFileName>FrameworkList.xml</FrameworkListFileName>
<FrameworkListOutputPath>$(ArtifactsObjDir)$(FrameworkListFileName)</FrameworkListOutputPath>
<!-- Platform manifest and package override metatdata -->
<ReferencePackSharedFxVersion>$(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).0</ReferencePackSharedFxVersion>
<ReferencePackSharedFxVersion Condition="'$(VersionSuffix)' != ''">$(ReferencePackSharedFxVersion)-$(VersionSuffix)</ReferencePackSharedFxVersion>
<!-- Runtime extensions transport paths -->
<RuntimeExtensionsReferenceDirectory>$(PkgMicrosoft_Extensions_Internal_Transport)\ref\$(TargetFramework)\</RuntimeExtensionsReferenceDirectory>
@ -120,12 +116,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<Output TaskParameter="JoinResult" ItemName="_ReferencedExtensionsRefAssemblies" />
</JoinItems>
<!-- _DuplicatedExtensionsRefAssemblies represents ref assemblies that are present in Microsoft.Extensions.Internal.Transport package and also are built in this repo. -->
<!-- This should be temporary while we migrate sources since there should be no duplication when sources are deleted from extensions. -->
<JoinItems Left="@(_ReferencedExtensionsRefAssemblies)" Right="@(_ResolvedProjectReferencePaths)" LeftKey="Filename" RightKey="Filename" ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_DuplicatedExtensionsRefAssemblies" />
</JoinItems>
<JoinItems Left="@(_ReferencedExtensionsRefAssemblies)" Right="@(ExternalAspNetCoreAppReference)" LeftKey="Filename" RightKey="Identity" ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_SelectedExtensionsRefs" />
</JoinItems>
@ -135,15 +125,12 @@ This package is an internal implementation of the .NET Core SDK and is not meant
</JoinItems>
<ItemGroup>
<!-- Do not exclude the ref assemblies that we built in this repo if it's also included in Microsoft.Extensions.Internal.Transport -->
<_ReferencedExtensionsRefAssembliesToExclude Include="@(_ReferencedExtensionsRefAssemblies)" Exclude="@(_DuplicatedExtensionsRefAssemblies)" />
<!-- Exclude transitive external dependencies that are not directly referenced by projects in AspNetCore or Extensions -->
<AspNetCoreReferenceAssemblyPath
Include="@(ReferencePathWithRefAssemblies)"
Condition="'%(ReferencePathWithRefAssemblies.IsReferenceAssembly)' != 'false'"
Exclude="
@(_ReferencedExtensionsRefAssembliesToExclude);
@(_ReferencedExtensionsRefAssemblies);
@(ReferencePathWithRefAssemblies->WithMetadataValue('NuGetPackageId', 'Microsoft.NETCore.App.Ref'));
@(ReferencePathWithRefAssemblies->WithMetadataValue('NuGetPackageId', 'System.Security.Cryptography.Pkcs'));
@(ReferencePathWithRefAssemblies->WithMetadataValue('NuGetPackageId', 'System.Drawing.Common'));
@ -172,7 +159,7 @@ This package is an internal implementation of the .NET Core SDK and is not meant
<_AspNetCoreAppPackageOverrides Include="@(AspNetCoreReferenceAssemblyPath->'%(NuGetPackageId)|%(NuGetPackageVersion)')" Condition="!Exists('$(RuntimeExtensionsReferenceDirectory)%(AspNetCoreReferenceAssemblyPath.NuGetPackageId).dll') AND '%(AspNetCoreReferenceAssemblyPath.NuGetPackageId)' != 'Microsoft.NETCore.App' AND '%(AspNetCoreReferenceAssemblyPath.NuGetPackageId)' != 'Microsoft.Extensions.Internal.Transport' AND '%(AspNetCoreReferenceAssemblyPath.NuGetSourceType)' == 'Package' " />
<!-- Pin version for extensions references -->
<_AspNetCoreAppPackageOverrides Include="@(_SelectedExtensionsRefAssemblies->'%(FileName)|$(MicrosoftInternalExtensionsRefsPackageOverrideVersion)')" />
<_AspNetCoreAppPackageOverrides Include="@(_SelectedExtensionsRefAssemblies->'%(FileName)|$(MicrosoftExtensionsInternalTransportPackageVersion)')" />
<_AspNetCoreAppPackageOverrides Include="@(AspNetCoreReferenceAssemblyPath->'%(FileName)|$(ReferencePackSharedFxVersion)')" Condition=" '%(AspNetCoreReferenceAssemblyPath.ReferenceSourceTarget)' == 'ProjectReference' AND '%(AspNetCoreReferenceAssemblyPath.IsReferenceAssembly)' == 'true' " />
</ItemGroup>

View File

@ -90,6 +90,28 @@
<_Parameter2>@(_TargetingPackDependencies)</_Parameter2>
</AssemblyAttribute>
<AspNetCoreTargetingPackDependencies
Include="@(_TargetingPackDependencies)"
Condition="'%(_TargetingPackDependencies.ReferenceSourceTarget)' == 'ProjectReference'" />
<RuntimeTargetingPackDependencies
Include="@(_TargetingPackDependencies)"
Exclude="@(AspNetCoreTargetingPackDependencies)" />
<AssemblyAttribute Include="Microsoft.AspNetCore.TestData">
<_Parameter1>AspNetCoreTargetingPackDependencies</_Parameter1>
<_Parameter2>@(AspNetCoreTargetingPackDependencies->'%(FileName)')</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.TestData">
<_Parameter1>RuntimeTargetingPackDependencies</_Parameter1>
<_Parameter2>@(RuntimeTargetingPackDependencies->'%(FileName)')</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.TestData">
<_Parameter1>ReferencePackSharedFxVersion</_Parameter1>
<_Parameter2>$(ReferencePackSharedFxVersion)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="Microsoft.AspNetCore.TestData">
<_Parameter1>RepositoryCommit</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>

View File

@ -32,6 +32,50 @@ namespace Microsoft.AspNetCore
_isTargetingPackBuilding = bool.Parse(TestData.GetTestDataValue("IsTargetingPackBuilding"));
}
[Fact]
public void PackageOverridesContainsCorrectEntries()
{
if (!_isTargetingPackBuilding)
{
return;
}
var packageOverridePath = Path.Combine(_targetingPackRoot, "data", "PackageOverrides.txt");
AssertEx.FileExists(packageOverridePath);
var packageOverrideFileLines = File.ReadAllLines(packageOverridePath);
var runtimeDependencies = TestData.GetRuntimeTargetingPackDependencies()
.Split(';', StringSplitOptions.RemoveEmptyEntries)
.ToHashSet();
var aspnetcoreDependencies = TestData.GetAspNetCoreTargetingPackDependencies()
.Split(';', StringSplitOptions.RemoveEmptyEntries)
.ToHashSet();
Assert.Equal(packageOverrideFileLines.Length, runtimeDependencies.Count + aspnetcoreDependencies.Count);
foreach (var entry in packageOverrideFileLines)
{
var packageOverrideParts = entry.Split("|");
var packageName = packageOverrideParts[0];
var packageVersion = packageOverrideParts[1];
if (runtimeDependencies.Contains(packageName))
{
Assert.Equal(TestData.GetMicrosoftNETCoreAppPackageVersion(), packageVersion);
}
else if (aspnetcoreDependencies.Contains(packageName))
{
Assert.Equal(TestData.GetReferencePackSharedFxVersion(), packageVersion);
}
else
{
Assert.True(false, $"{packageName} is not a recognized aspNetCore or runtime dependency");
}
}
}
[Fact]
public void AssembliesAreReferenceAssemblies()
{

View File

@ -13,6 +13,8 @@ namespace Microsoft.AspNetCore
public static string GetMicrosoftNETCoreAppPackageVersion() => GetTestDataValue("MicrosoftNETCoreAppRuntimeVersion");
public static string GetReferencePackSharedFxVersion() => GetTestDataValue("ReferencePackSharedFxVersion");
public static string GetRepositoryCommit() => GetTestDataValue("RepositoryCommit");
public static string GetSharedFxRuntimeIdentifier() => GetTestDataValue("TargetRuntimeIdentifier");
@ -21,6 +23,10 @@ namespace Microsoft.AspNetCore
public static string GetTargetingPackDependencies() => GetTestDataValue("TargetingPackDependencies");
public static string GetRuntimeTargetingPackDependencies() => GetTestDataValue("RuntimeTargetingPackDependencies");
public static string GetAspNetCoreTargetingPackDependencies() => GetTestDataValue("AspNetCoreTargetingPackDependencies");
public static bool VerifyAncmBinary() => string.Equals(GetTestDataValue("VerifyAncmBinary"), "true", StringComparison.OrdinalIgnoreCase);
public static string GetTestDataValue(string key)