Skip to content

Commit 392b35c

Browse files
authored
Ensure UserSecretsIdAttribute is added to assembly (#63415)
When Microsoft.Extensions.Configuration.UserSecrets is referenced transitively, for example through Extensions.Hosting, the UserSecretsIdAttribute isn't getting added to the built assembly. This is because the logic is contained in a `build` folder which is excluded by the dependency from Extensions.Hosting. The fix is to move the logic to `buildTransitive`, so it gets picked up by NuGet. One wrinkle is that the logic now conflicts with the netstandard compatibility logic added by the library infrastructure. In order to make progress, disable that logic for this package and rely on its dependencies to raise the compat error. Contributes to #63246
1 parent 0b7bef0 commit 392b35c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/Microsoft.Extensions.Configuration.UserSecrets.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
<DisableImplicitAssemblyReferences>false</DisableImplicitAssemblyReferences>
88
<IsPackable>true</IsPackable>
99
<PackageDescription>User secrets configuration provider implementation for Microsoft.Extensions.Configuration.</PackageDescription>
10+
11+
<!--
12+
See https://github.com/dotnet/runtime/issues/63413.
13+
Since this library contains its own buildTransitive logic, disable the netstandard compat logic since they conflict.
14+
-->
15+
<DisableNETStandardCompatErrorForNETCoreApp>true</DisableNETStandardCompatErrorForNETCoreApp>
16+
<DisableNETStandardCompatErrorForNETFramework>true</DisableNETStandardCompatErrorForNETFramework>
1017
</PropertyGroup>
1118

1219
<ItemGroup>
@@ -17,8 +24,8 @@
1724
</ItemGroup>
1825

1926
<ItemGroup>
20-
<Content Include="build\netstandard2.0\$(MSBuildProjectName).props" PackagePath="%(Identity)" />
21-
<Content Include="build\netstandard2.0\$(MSBuildProjectName).targets" PackagePath="%(Identity)" />
27+
<Content Include="buildTransitive\netstandard2.0\$(MSBuildProjectName).props" PackagePath="%(Identity)" />
28+
<Content Include="buildTransitive\netstandard2.0\$(MSBuildProjectName).targets" PackagePath="%(Identity)" />
2229
</ItemGroup>
2330

2431
</Project>

src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props renamed to src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/buildTransitive/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.props

File renamed without changes.

src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/build/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets renamed to src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/buildTransitive/netstandard2.0/Microsoft.Extensions.Configuration.UserSecrets.targets

File renamed without changes.

0 commit comments

Comments
 (0)