Skip to content

Commit

Permalink
add net461 target for cache extensions (#737)
Browse files Browse the repository at this point in the history
* add net461 target for cache extensions

* change to 472

* add claimsprincipalextensions
  • Loading branch information
jennyf19 authored Nov 3, 2020
1 parent 529c83f commit d5e0a20
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Microsoft.Identity.Web/ClaimsPrincipalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,12 @@ public static class ClaimsPrincipalExtensions

return claimsPrincipal.FindFirstValue(ClaimConstants.NameIdentifierId);
}

#if NET472
private static string? FindFirstValue(this ClaimsPrincipal claimsPrincipal, string type)
{
return claimsPrincipal.FindFirst(type)?.Value;
}
#endif
}
}
29 changes: 26 additions & 3 deletions src/Microsoft.Identity.Web/Microsoft.Identity.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>


<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net472; net5.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -61,6 +60,11 @@
<DefineConstants>$(DefineConstants);DOTNET_50_AND_ABOVE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
<DefineConstants>$(DefineConstants);DOTNET_472</DefineConstants>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<PropertyGroup>
<!-- The MSAL.snk has both private and public keys -->
<DelaySign>false</DelaySign>
Expand All @@ -80,10 +84,29 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.8" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
<Compile Remove="*.cs"/>
<Compile Include="ClaimsPrincipalExtensions.cs" />
<Compile Remove="AppServicesAuth\**" />
<Compile Remove="CertificateManagement\**" />
<Compile Remove="DownstreamWebApiSupport\**" />
<Compile Remove="InstanceDiscovery\**" />
<Compile Remove="Resource\**" />
<Compile Remove="WebApiExtensions\**" />
<Compile Remove="WebAppExtensions\**" />
<Compile Remove="TokenCacheProviders\Session\**" />
<Compile Remove="TokenCacheProviders\Distributed\DistributedTokenCacheAdapterExtension.cs" />
<Compile Remove="TokenCacheProviders\InMemory\InMemoryTokenCacheProviderExtension.cs" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net472' ">
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.1.0" />
<PackageReference Include="Azure.Identity" Version="1.2.3" />
<PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1; net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1; net472; net5.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../build/MSAL.snk</AssemblyOriginatorKeyFile>
Expand All @@ -22,6 +22,13 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472' ">
<Compile Remove="Mocks\LoggerMock.cs" />
<Compile Remove="TestHelpers\HttpContextUtilities.cs" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Microsoft.Identity.Web.TokenCacheProviders;
Expand Down

0 comments on commit d5e0a20

Please sign in to comment.