Skip to content

Commit 0b0bed3

Browse files
authored
Expose all references when not restoring (#32718)
* Expose all references when not restoring - use empty `$(MSBuildRestoreSessionId)` to determine when contributing to dependency graph * Remove extra direct references - should now be part of the dependency graph automatically * Avoid errors about non-shared Fx references - not a problem unless executing `restore` target * Special case source builds
1 parent 49d58b1 commit 0b0bed3

File tree

35 files changed

+24
-67
lines changed

35 files changed

+24
-67
lines changed

eng/targets/ResolveReferences.targets

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@
110110
In addition, enforce use of Reference items for projects reference providers.
111111
-->
112112
<Target Name="_CheckForReferenceBoundaries" BeforeTargets="CollectPackageReferences;ResolveReferences">
113+
<!-- Dependency graph checks may include unexpected packages. Ignore this because it's not an error. -->
113114
<Error
114-
Condition="@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0 AND '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)'"
115+
Condition=" '$(TargetFramework)' == '$(DefaultNetCoreTargetFramework)' AND
116+
'$(MSBuildRestoreSessionId)' != '' AND
117+
@(_InvalidReferenceToNonSharedFxAssembly->Count()) != 0 "
115118
Text="Cannot reference &quot;%(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." />
116119

117120
<Error

src/Components/Ignitor/src/Ignitor.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
<Reference Include="Microsoft.AspNetCore.SignalR.Client" />
3333
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" />
3434
<Reference Include="Microsoft.Extensions.Logging.Console" />
35-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
36-
<Reference Include="Microsoft.AspNetCore.SignalR.Common" />
3735
</ItemGroup>
3836

3937
<ItemGroup>

src/Components/WebAssembly/testassets/Wasm.Authentication.Server/Wasm.Authentication.Server.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
65

76
<!-- This project references the shared framework transitively. Prevent restore errors by setting this flag. -->
87
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
@@ -21,7 +20,6 @@
2120
<Reference Include="Microsoft.EntityFrameworkCore.Relational" />
2221
<Reference Include="Microsoft.EntityFrameworkCore.SQLite" />
2322
<Reference Include="Microsoft.Extensions.Hosting" />
24-
2523
</ItemGroup>
2624

2725
<ItemGroup>

src/DataProtection/DataProtection/src/Microsoft.AspNetCore.DataProtection.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
<Reference Include="System.Security.Cryptography.Xml" />
3131
</ItemGroup>
3232

33-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
33+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(MSBuildRestoreSessionId)' == ''">
3434
<Reference Include="System.Security.Principal.Windows" />
3535
</ItemGroup>
3636

37-
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetFxTargetFramework)'">
37+
<ItemGroup Condition="'$(TargetFramework)' == '$(DefaultNetFxTargetFramework)' OR '$(MSBuildRestoreSessionId)' == ''">
3838
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
3939
</ItemGroup>
4040

src/DataProtection/EntityFrameworkCore/test/Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.Test.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<ItemGroup>
88
<Reference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" />
99
<Reference Include="Microsoft.EntityFrameworkCore.InMemory" />
10-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
11-
<Reference Include="Microsoft.AspNetCore.DataProtection" />
1210
</ItemGroup>
1311

1412
</Project>

src/DataProtection/StackExchangeRedis/test/Microsoft.AspNetCore.DataProtection.StackExchangeRedis.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
<Reference Include="Microsoft.Extensions.Configuration.Json" />
1717
<Reference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
1818
<Reference Include="Microsoft.Extensions.DependencyInjection" />
19-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
20-
<Reference Include="Microsoft.AspNetCore.DataProtection" />
2119
</ItemGroup>
2220

2321
</Project>

src/DataProtection/samples/EntityFrameworkCoreSample/EntityFrameworkCoreSample.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<Reference Include="Microsoft.EntityFrameworkCore.SqlServer" />
1212
<Reference Include="Microsoft.Extensions.DependencyInjection" />
1313
<Reference Include="Microsoft.Extensions.Logging.Console" />
14-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
15-
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
1614
</ItemGroup>
1715

1816
</Project>

src/DataProtection/samples/Redis/Redis.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<Reference Include="Microsoft.Extensions.DependencyInjection" />
1111
<Reference Include="Microsoft.Extensions.Logging" />
1212
<Reference Include="Microsoft.Extensions.Logging.Console" />
13-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
14-
<Reference Include="Microsoft.AspNetCore.DataProtection" />
1513
</ItemGroup>
1614

1715
</Project>

src/Identity/ApiAuthorization.IdentityServer/samples/ApiAuthSample/ApiAuthSample.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
<Reference Include="Microsoft.Extensions.Logging.Configuration" />
3636
<Reference Include="Microsoft.Extensions.Logging.Console" />
3737
<Reference Include="Microsoft.Extensions.Logging.Debug" />
38-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
39-
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
4038
</ItemGroup>
4139

4240
</Project>

src/Identity/EntityFrameworkCore/test/EF.InMemory.Test/Microsoft.AspNetCore.Identity.EntityFrameworkCore.InMemory.Test.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
<Reference Include="Microsoft.AspNetCore.Hosting" />
1616
<Reference Include="Microsoft.AspNetCore.Http" />
1717
<Reference Include="Microsoft.EntityFrameworkCore.Sqlite" />
18-
<!-- Avoid CS1705 errors due to mix of assemblies brought in transitively. -->
19-
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
2018
</ItemGroup>
2119

2220
</Project>

0 commit comments

Comments
 (0)