Skip to content

Fix package overrides #21329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Framework/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
17 changes: 2 additions & 15 deletions src/Framework/ref/Microsoft.AspNetCore.App.Ref.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand All @@ -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'));
Expand Down Expand Up @@ -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>
Expand Down
22 changes: 22 additions & 0 deletions src/Framework/test/Microsoft.AspNetCore.App.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
44 changes: 44 additions & 0 deletions src/Framework/test/TargetingPackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,50 @@ public TargetingPackTests(ITestOutputHelper output)
_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()
{
Expand Down
6 changes: 6 additions & 0 deletions src/Framework/test/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class TestData

public static string GetMicrosoftNETCoreAppPackageVersion() => GetTestDataValue("MicrosoftNETCoreAppRuntimeVersion");

public static string GetReferencePackSharedFxVersion() => GetTestDataValue("ReferencePackSharedFxVersion");

public static string GetRepositoryCommit() => GetTestDataValue("RepositoryCommit");

public static string GetSharedFxRuntimeIdentifier() => GetTestDataValue("TargetRuntimeIdentifier");
Expand All @@ -21,6 +23,10 @@ public class TestData

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)
Expand Down