Automatically set 'PrivateAssets=All' for .Sources references (#7539)

When a `<Reference>` is named `*.Sources`, set PrivateAssets=All (exclude from generated nuspec) and IncludeAssets=ContentFiles (only consume content files, not .dll's)
This commit is contained in:
Nate McMaster 2019-02-13 14:31:15 -08:00 committed by GitHub
parent cddbc2e888
commit 338de4710a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 52 additions and 47 deletions

View File

@ -48,7 +48,17 @@
<UseProjectReferences Condition=" '$(UseProjectReferences)' == '' ">false</UseProjectReferences>
</PropertyGroup>
<ItemDefinitionGroup>
<Reference>
<IsSharedSource></IsSharedSource>
</Reference>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Update="@(Reference)">
<IsSharedSource Condition="'%(IsSharedSource)' == '' AND $([System.String]::new('%(Identity)').EndsWith('.Sources'))">true</IsSharedSource>
</Reference>
<!-- Packages which are implicitly defined by the .NET Core SDK. -->
<_ImplicitPackageReference Include="@(PackageReference->WithMetadataValue('IsImplicitlyDefined', 'true'))" />
<!-- Capture a list of references which were set explicitly in the project. -->
@ -67,7 +77,8 @@
@(AspNetCoreAppReference);
@(AspNetCoreAppReferenceAndPackage);
@(ExternalAspNetCoreAppReference);
@(_CompilationOnlyReference)" />
@(_CompilationOnlyReference);
@(Reference->WithMetadataValue('IsSharedSource', 'true'))" />
<!-- TODO: remove Newtonsoft.Json from this list once https://github.com/aspnet/AspNetCore/issues/4260 is resolved -->
<!--
@ -87,12 +98,6 @@
<Reference Remove="@(Reference)" />
</ItemGroup>
<ItemDefinitionGroup>
<Reference>
<SharedSources>false</SharedSources>
</Reference>
</ItemDefinitionGroup>
<!--
This target resolves remaining Referene items to Packages, if possible. If not, they are left as Reference items fo the SDK to resolve.
This target helps ensure projects within the shared framework do no unintentionally add new references,
@ -104,7 +109,7 @@
<Error Condition="@(_InvalidReferenceToSharedFxOnlyAssembly->Count()) != 0"
Text="Cannot reference &quot;%(_InvalidReferenceToSharedFxOnlyAssembly.Identity)&quot; directly because it is part of the shared framework and this project is not. Use &lt;FrameworkReference Include=&quot;Microsoft.AspNetCore.App&quot; /&gt; instead." />
<Error Condition="@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0 AND '%(_InvalidReferenceToNonSharedFxAssembly.SharedSources)' != 'true'"
<Error Condition="@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0"
Text="Cannot reference &quot;%(_InvalidReferenceToNonSharedFxAssembly.Identity)&quot;. This dependency is not in the shared framework. See docs/SharedFramework.md for instructions on how to modify what is in the shared framework." />
</Target>
@ -119,8 +124,8 @@
<!-- Ensure only content asset are consumed from .Sources packages -->
<Reference>
<IncludeAssets Condition="'%(SharedSources)' == 'true'">ContentFiles</IncludeAssets>
<PrivateAssets Condition="'%(SharedSources)' == 'true'">All</PrivateAssets>
<IncludeAssets Condition="'%(IsSharedSource)' == 'true'">ContentFiles</IncludeAssets>
<PrivateAssets Condition="'%(IsSharedSource)' == 'true'">All</PrivateAssets>
</Reference>
<!-- Identify if any references were present in the last release of this package, but have been removed. -->

View File

@ -39,7 +39,7 @@
<ItemGroup>
<ProjectReference Condition="'$(BuildNodeJS)' != 'false'" Include="$(RepositoryRoot)src\Components\Browser.JS\src\Microsoft.AspNetCore.Components.Browser.JS.npmproj" ReferenceOutputAssembly="false" />
<Reference Include="Microsoft.AspNetCore.Components" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="Microsoft.Extensions.FileProviders.Composite" />
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
<Reference Include="Mono.Cecil" />

View File

@ -17,7 +17,7 @@
<Reference Include="Microsoft.AspNetCore.Components.Server" />
<Reference Include="Microsoft.AspNetCore.ResponseCompression" />
<Reference Include="Microsoft.AspNetCore" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
</ItemGroup>
<!--

View File

@ -10,7 +10,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.Components" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
</ItemGroup>
</Project>

View File

@ -26,7 +26,7 @@
<Reference Include="Microsoft.Extensions.Hosting.Abstractions" />
<Reference Include="Microsoft.Extensions.Logging" />
<Reference Include="Microsoft.Extensions.Options" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" />
</ItemGroup>
</Project>

View File

@ -11,7 +11,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Hosting" />
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
<Reference Include="System.IO.Pipelines" />
</ItemGroup>

View File

@ -21,7 +21,7 @@ Microsoft.AspNetCore.Http.HttpResponse</Description>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Features" />
<Reference Include="Microsoft.Extensions.ActivatorUtilities.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.ActivatorUtilities.Sources" />
<Reference Include="System.Text.Encodings.Web" />
</ItemGroup>

View File

@ -12,7 +12,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.Http" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
</ItemGroup>
</Project>

View File

@ -37,7 +37,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
<Reference Include="Microsoft.AspNetCore.Http" />
<Reference Include="Microsoft.AspNetCore.Routing" />
<Reference Include="Microsoft.Extensions.DependencyInjection" />

View File

@ -28,7 +28,7 @@ Microsoft.AspNetCore.Routing.RouteCollection</Description>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Extensions" />
<Reference Include="Microsoft.AspNetCore.Routing.Abstractions" />
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.ObjectPool" />
<Reference Include="Microsoft.Extensions.Options" />

View File

@ -9,7 +9,7 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json" />
<Reference Include="Microsoft.AspNetCore.Routing" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
</ItemGroup>
</Project>

View File

@ -24,7 +24,7 @@
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" />
</ItemGroup>
</Project>

View File

@ -8,7 +8,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.Http" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
<Reference Include="Microsoft.AspNetCore.ResponseCompression" />
<Reference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>

View File

@ -21,7 +21,7 @@ Microsoft.AspNetCore.Mvc.IActionResult</Description>
</ItemGroup>
<ItemGroup Label="Sources packages">
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" />
</ItemGroup>
</Project>

View File

@ -44,9 +44,9 @@ Microsoft.AspNetCore.Mvc.RouteAttribute</Description>
</ItemGroup>
<ItemGroup Label="Sources packages">
<Reference Include="Microsoft.Extensions.ParameterDefaultValue.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.ParameterDefaultValue.Sources" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" />
</ItemGroup>
</Project>

View File

@ -12,7 +12,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.TestHost" />
<Reference Include="Microsoft.AspNetCore.Mvc.Core" />
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
<Reference Include="Microsoft.Extensions.Hosting" />
</ItemGroup>

View File

@ -20,7 +20,7 @@
<ItemGroup>
<Reference Include="AngleSharp" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="Selenium.Support" />
<Reference Include="Selenium.WebDriver.MicrosoftDriver" />
<Reference Include="Selenium.WebDriver" />

View File

@ -20,7 +20,7 @@ Microsoft.AspNetCore.Razor.TagHelpers.ITagHelper</Description>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Html.Abstractions" />
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.HashCodeCombiner.Sources" />
</ItemGroup>
</Project>

View File

@ -12,7 +12,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Authorization.Policy" />
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
<Reference Include="Microsoft.AspNetCore.Http" />
<Reference Include="Microsoft.Extensions.DependencyInjection" />
<Reference Include="Microsoft.Extensions.Logging" />

View File

@ -12,7 +12,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Features" />
<Reference Include="Microsoft.Extensions.ActivatorUtilities.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.ActivatorUtilities.Sources" />
<Reference Include="System.IO.Pipelines" />
</ItemGroup>

View File

@ -39,7 +39,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
</ItemGroup>

View File

@ -17,7 +17,7 @@
<ItemGroup>
<Reference Include="BenchmarkDotNet" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.AspNetCore.BenchmarkRunner.Sources" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Core" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" />

View File

@ -17,7 +17,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Http.Abstractions" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" />
<Reference Include="Newtonsoft.Json" />
</ItemGroup>

View File

@ -20,7 +20,7 @@
<Reference Include="FSharp.Core" />
<Reference Include="System.Reflection.Metadata" />
<Reference Include="System.Threading.Tasks.Extensions" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.TypeNameHelper.Sources" />
</ItemGroup>
<ItemGroup>

View File

@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'" >
<Reference Include="Microsoft.Bcl.Json.Sources" SharedSources="true" />
<Reference Include="Microsoft.Bcl.Json.Sources" />
<Reference Include="System.Buffers" />
</ItemGroup>

View File

@ -28,7 +28,7 @@
<Reference Include="Microsoft.AspNetCore.Http" />
<Reference Include="Microsoft.AspNetCore.Routing" />
<Reference Include="Microsoft.AspNetCore.WebSockets" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" SharedSources="true" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" />
<Reference Include="Newtonsoft.Json" />
<Reference Include="System.Security.Principal.Windows" />
</ItemGroup>

View File

@ -26,7 +26,7 @@
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="Microsoft.Bcl.Json.Sources" SharedSources="true" />
<Reference Include="Microsoft.Bcl.Json.Sources" />
<Reference Include="System.Buffers" />
</ItemGroup>

View File

@ -19,7 +19,7 @@
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" />
<Reference Include="Microsoft.AspNetCore.Testing" />
<Reference Include="Microsoft.Extensions.Logging.Testing" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" />
</ItemGroup>
</Project>

View File

@ -28,7 +28,7 @@
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" />
<Reference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" />
<Reference Include="Microsoft.Extensions.DependencyInjection" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.ValueStopwatch.Sources" />
<Reference Include="Moq" />
<Reference Include="System.Reactive.Linq" />
<Reference Include="System.Threading.Channels" />

View File

@ -8,7 +8,7 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.SignalR.Client" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="Newtonsoft.Json" />
</ItemGroup>

View File

@ -13,7 +13,7 @@
<Reference Include="Microsoft.AspNetCore.SignalR.Client" />
<Reference Include="Microsoft.Extensions.Logging.Console" />
<Reference Include="Microsoft.Extensions.Logging" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
</ItemGroup>
</Project>

View File

@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="System.Security.Cryptography.Cng" />
</ItemGroup>

View File

@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="System.Data.SqlClient" />
</ItemGroup>

View File

@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<Reference Include="Microsoft.Extensions.Configuration.UserSecrets" />
</ItemGroup>

View File

@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" PrivateAssets="All" />
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
</ItemGroup>
</Project>