@@ -21,7 +21,6 @@ internal class DependencyContextBuilder
2121 private Dictionary < string , List < ReferenceInfo > > _compileReferences ;
2222 private Dictionary < string , List < ResolvedFile > > _resolvedNuGetFiles ;
2323 private Dictionary < string , SingleProjectInfo > _referenceProjectInfos ;
24- private IEnumerable < string > _excludeFromPublishPackageIds ;
2524 private Dictionary < string , List < RuntimePackAssetInfo > > _runtimePackAssets ;
2625 private CompilationOptions _compilationOptions ;
2726 private string _referenceAssembliesPath ;
@@ -160,12 +159,6 @@ public DependencyContextBuilder WithMainProjectInDepsFile(bool includeMainProjec
160159 return this ;
161160 }
162161
163- public DependencyContextBuilder WithExcludeFromPublishAssets ( IEnumerable < string > excludeFromPublishPackageIds )
164- {
165- _excludeFromPublishPackageIds = excludeFromPublishPackageIds ;
166- return this ;
167- }
168-
169162 public DependencyContextBuilder WithRuntimePackAssets ( IEnumerable < RuntimePackAssetInfo > runtimePackAssets )
170163 {
171164 _runtimePackAssets = new Dictionary < string , List < RuntimePackAssetInfo > > ( ) ;
@@ -748,50 +741,6 @@ private void CalculateExcludedLibraries()
748741 {
749742 _dependencyLibraries [ packageToExcludeFromRuntime ] . ExcludeFromRuntime = true ;
750743 }
751-
752- if ( _excludeFromPublishPackageIds != null && _excludeFromPublishPackageIds . Any ( ) )
753- {
754- // Include transitive dependencies of all top-level dependencies which are not
755- // excluded from publish
756-
757- Dictionary < string , DependencyLibrary > includedDependencies = new Dictionary < string , DependencyLibrary > ( StringComparer . OrdinalIgnoreCase ) ;
758-
759- HashSet < string > excludeFromPublishPackageIds = new HashSet < string > ( _excludeFromPublishPackageIds ) ;
760-
761- Stack < string > dependenciesToWalk = new Stack < string > (
762- _mainProjectDependencies . Except ( _excludeFromPublishPackageIds , StringComparer . OrdinalIgnoreCase ) ) ;
763-
764- while ( dependenciesToWalk . Any ( ) )
765- {
766- var dependencyName = dependenciesToWalk . Pop ( ) ;
767- if ( ! includedDependencies . ContainsKey ( dependencyName ) )
768- {
769- // There may not be a library in the assets file if a referenced project has
770- // PrivateAssets="all" for a package reference, and there is a package in the graph
771- // that depends on the same packge.
772- if ( _dependencyLibraries . TryGetValue ( dependencyName , out var dependencyLibrary ) )
773- {
774- includedDependencies . Add ( dependencyName , dependencyLibrary ) ;
775- foreach ( var newDependency in _libraryDependencies [ dependencyName ] )
776- {
777- dependenciesToWalk . Push ( newDependency . Name ) ;
778- }
779- }
780- }
781- }
782-
783- foreach ( var dependencyLibrary in _dependencyLibraries . Values )
784- {
785- // Libraries explicitly marked as exclude from publish should be excluded from
786- // publish even if there are other transitive dependencies to them
787- if ( ! includedDependencies . ContainsKey ( dependencyLibrary . Name ) ||
788- excludeFromPublishPackageIds . Contains ( dependencyLibrary . Name ) )
789- {
790- dependencyLibrary . ExcludeFromCompilation = true ;
791- dependencyLibrary . ExcludeFromRuntime = true ;
792- }
793- }
794- }
795744 }
796745
797746 private string GetReferenceLibraryName ( ReferenceInfo reference )
0 commit comments