-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Stop shipping packages for assemblies which are shared-framework-only #4178
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
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- | ||
This lists all assemblies which are part of the Microsoft.AspNetCore.App shared framework | ||
and should not ship as NuGet packages. | ||
--> | ||
<Project> | ||
|
||
<Import Project="..\src\Framework\Microsoft.AspNetCore.App.props" /> | ||
|
||
<ItemGroup> | ||
<!-- Packages to be removed from the shared framework but not done yet. --> | ||
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.JsonPatch" /> | ||
|
||
<!-- Packages for Razor runtime compilation --> | ||
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.Razor.Language" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.CodeAnalysis.Razor" /> | ||
|
||
<!-- Assemblies required by the SignalR client. --> | ||
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.Http.Features" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Common" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.AspNetCore.SignalR.Protocols.Json" /> | ||
|
||
<!-- Assemblies produced by this repo that will move to aspnet/Extensions after repo refactoring is tone --> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Diagnostics.HealthChecks" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Identity.Core" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Identity.Stores" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Localization.Abstractions" /> | ||
<SharedFrameworkAndPackage Include="Microsoft.Extensions.Localization" /> | ||
|
||
<SharedFrameworkOnlyPackage Include="@(Dependency)" Exclude="@(SharedFrameworkAndPackage)" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using NuGet.Packaging; | ||
using NuGet.Packaging.Core; | ||
|
||
namespace RepoTasks | ||
{ | ||
// This is temporary until we can use FrameworkReference to build our own packages | ||
public class RemoveSharedFrameworkDependencies : Task | ||
{ | ||
[Required] | ||
public ITaskItem[] Files { get; set; } | ||
|
||
[Required] | ||
public ITaskItem[] FrameworkOnlyPackages { get; set; } | ||
|
||
public override bool Execute() | ||
{ | ||
var dependencyToRemove = FrameworkOnlyPackages.Select(p => p.ItemSpec).ToHashSet(StringComparer.OrdinalIgnoreCase); | ||
|
||
foreach (var file in Files) | ||
{ | ||
FilterDependencies(file.ItemSpec, dependencyToRemove); | ||
} | ||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
private void FilterDependencies(string targetPath, ISet<string> dependencyToRemove) | ||
{ | ||
var fileName = Path.GetFileName(targetPath); | ||
Log.LogMessage($"Updating {fileName}"); | ||
|
||
using (var fileStream = File.Open(targetPath, FileMode.Open)) | ||
using (var package = new ZipArchive(fileStream, ZipArchiveMode.Update)) | ||
using (var packageReader = new PackageArchiveReader(fileStream, leaveStreamOpen: true)) | ||
{ | ||
var dirty = false; | ||
var nuspecFile = packageReader.GetNuspecFile(); | ||
using (var stream = package.OpenFile(nuspecFile)) | ||
{ | ||
var reader = Manifest.ReadFrom(stream, validateSchema: true); | ||
stream.Position = 0; | ||
var packageBuilder = new PackageBuilder(stream, basePath: null); | ||
var updatedGroups = new List<PackageDependencyGroup>(); | ||
|
||
foreach (var group in packageBuilder.DependencyGroups) | ||
{ | ||
var packages = new List<PackageDependency>(); | ||
var updatedGroup = new PackageDependencyGroup(group.TargetFramework, packages); | ||
foreach (var dependency in group.Packages) | ||
{ | ||
if (dependencyToRemove.Contains(dependency.Id)) | ||
{ | ||
dirty = true; | ||
Log.LogMessage($" Remove dependency on '{dependency.Id}'"); | ||
continue; | ||
} | ||
|
||
packages.Add(dependency); | ||
} | ||
|
||
updatedGroups.Add(updatedGroup); | ||
} | ||
|
||
if (dirty) | ||
{ | ||
packageBuilder.DependencyGroups.Clear(); | ||
packageBuilder.DependencyGroups.AddRange(updatedGroups); | ||
|
||
var updatedManifest = Manifest.Create(packageBuilder); | ||
stream.Position = 0; | ||
stream.SetLength(0); | ||
updatedManifest.Save(stream); | ||
} | ||
else | ||
{ | ||
Log.LogMessage($"No changes made to {fileName}"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.