Skip to content

Fix UserSecretsIdAttribute generation #4177

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 1 commit into from
Nov 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Framework/pkg/Microsoft.AspNetCore.App.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,27 @@
Text="This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp3.0 target framework. Please target netcoreapp3.0 or choose a version of Microsoft.AspNetCore.App compatible with $(TargetFramework)."
Condition="'$(TargetFramework)' != 'netcoreapp3.0'"/>
</Target>

<!--
Adds metadata so the SDK will generate the UserSecretsIdAttribute.

If GeneratedUserSecretsAttributeFile is set, that means Microsoft.Extensions.Configuration.UserSecrets 2.1
or earlier was referenced as a package. This didn't use the AssemblyAttribute item group, so we cannot
avoid duplicate AssemblyAttribute items without skipping this target altogether..
-->
<Target Name="_GetUserSecretsAssemblyAttribute"
BeforeTargets="GetAssemblyAttributes"
Condition="' $(UserSecretsId)' != '' AND '$(GenerateUserSecretsAttribute)' != 'false' AND '$(GeneratedUserSecretsAttributeFile)' == '' ">

<!--
If the Microsoft.Extensions.Configuration.UserSecrets package 2.2 or higher is referenced directly,
it will also add an AssemblyAttribute item. Since this attribute only allows one per assembly, do not
duplicate the item.
-->
<ItemGroup Condition=" @(AssemblyAttribute->WithMetadataValue('Identity', 'Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute')->Count()) == 0 ">
<AssemblyAttribute Include="Microsoft.Extensions.Configuration.UserSecrets.UserSecretsIdAttribute">
<_Parameter1>$(UserSecretsId.Trim())</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>
</Project>