diff --git a/AuthStudy.Authentication.Basic/AuthStudy.Authentication.Basic.csproj b/AuthStudy.Authentication.Basic/AuthStudy.Authentication.Basic.csproj index a636233..3cc0a7d 100644 --- a/AuthStudy.Authentication.Basic/AuthStudy.Authentication.Basic.csproj +++ b/AuthStudy.Authentication.Basic/AuthStudy.Authentication.Basic.csproj @@ -7,6 +7,7 @@ </PropertyGroup> <ItemGroup> + <FrameworkReference Include="Microsoft.AspNetCore.App" /> <ProjectReference Include="..\AuthStudy.Authentication.Shared\AuthStudy.Authentication.Shared.csproj" /> </ItemGroup> diff --git a/AuthStudy.Authentication.Basic/BasicAuthenticationDefaults.cs b/AuthStudy.Authentication.Basic/BasicAuthenticationDefaults.cs new file mode 100644 index 0000000..982b9c5 --- /dev/null +++ b/AuthStudy.Authentication.Basic/BasicAuthenticationDefaults.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AuthStudy.Authentication.Basic +{ + internal class BasicAuthenticationDefaults + { + } +} diff --git a/AuthStudy.Authentication.Basic/BasicAuthenticationExtensions.cs b/AuthStudy.Authentication.Basic/BasicAuthenticationExtensions.cs new file mode 100644 index 0000000..541a0fa --- /dev/null +++ b/AuthStudy.Authentication.Basic/BasicAuthenticationExtensions.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AuthStudy.Authentication.Basic +{ + internal class BasicAuthenticationExtensions + { + } +} diff --git a/AuthStudy.Authentication.Basic/BasicAuthenticationHandler.cs b/AuthStudy.Authentication.Basic/BasicAuthenticationHandler.cs new file mode 100644 index 0000000..ceed023 --- /dev/null +++ b/AuthStudy.Authentication.Basic/BasicAuthenticationHandler.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AuthStudy.Authentication.Basic +{ + internal class BasicAuthenticationHandler + { + } +} diff --git a/AuthStudy.Authentication.Basic/BasicAuthenticationOptions.cs b/AuthStudy.Authentication.Basic/BasicAuthenticationOptions.cs new file mode 100644 index 0000000..7a7d595 --- /dev/null +++ b/AuthStudy.Authentication.Basic/BasicAuthenticationOptions.cs @@ -0,0 +1,13 @@ + +using Microsoft.AspNetCore.Authentication; + +namespace AuthStudy.Authentication.Basic +{ + public class BasicAuthenticationOptions : AuthenticationSchemeOptions + { + public BasicAuthenticationOptions() + { + + } + } +} \ No newline at end of file diff --git a/AuthStudy.Authentication.Basic/Class1.cs b/AuthStudy.Authentication.Basic/Class1.cs deleted file mode 100644 index 4ad8e6b..0000000 --- a/AuthStudy.Authentication.Basic/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace AuthStudy.Authentication.Basic -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/AuthStudy.Authentication.Browser/AuthStudy.Authentication.Browser.csproj b/AuthStudy.Authentication.Browser/AuthStudy.Authentication.Browser.csproj index 70018f1..18c26a9 100644 --- a/AuthStudy.Authentication.Browser/AuthStudy.Authentication.Browser.csproj +++ b/AuthStudy.Authentication.Browser/AuthStudy.Authentication.Browser.csproj @@ -7,8 +7,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" /> - <PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" /> + <FrameworkReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="7.0.5" /> <PackageReference Include="Microsoft.Extensions.Features" Version="7.0.5" /> <PackageReference Include="UAParser" Version="3.1.47" /> diff --git a/AuthStudy.sln b/AuthStudy.sln index f0e0b08..b331da4 100644 --- a/AuthStudy.sln +++ b/AuthStudy.sln @@ -20,6 +20,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "授权", "授权", "{74577ADF-0E82-4798-8D49-AA70DD82528A}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{947159C1-414A-4927-A77B-7A37C8A20BDD}" + ProjectSection(SolutionItems) = preProject + Docs\说明.md = Docs\说明.md + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Docs/说明.md b/Docs/说明.md new file mode 100644 index 0000000..0039b9c --- /dev/null +++ b/Docs/说明.md @@ -0,0 +1,80 @@ +说明 +==== + +## 关于 共享框架 +随着 .NET Core 3.0 的发布,许多 ASP.NET Core 程序集不再作为包发布到 NuGet。 +相反,程序集包含在 Microsoft.AspNetCore.App 共享框架中,该框架随 .NET Core SDK 和运行时安装程序一起安装。 + ++ Web项目,一般自动包含 AspMicrosoft.AspNetCore.App 共享框架,即 共享框架由项目的Sdk属性(Microsoft.NET.Sdk.Web)自动引入 +```xml +<Project Sdk="Microsoft.NET.Sdk.Web"> + <!--共享项目由上面Sdk类型(Microsoft.NET.Sdk.Web)自动引入--> + <PropertyGroup> + <TargetFramework>net7.0</TargetFramework> + <Nullable>enable</Nullable> + <ImplicitUsings>enable</ImplicitUsings> + </PropertyGroup> + + <ItemGroup> + <!--Nuget包引用--> + <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> + <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> + </ItemGroup> + + <ItemGroup> + <!--项目引用--> + <ProjectReference Include="..\xx.csproj" /> + </ItemGroup> + +</Project> +``` ++ 类库项目等,要手动引入(无法使用nuget包的方式引入) +```xml +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net7.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <!-- 手动引入共享框架(不指定版本,自动跟随项目版本),多目标项目,也可以使用变量根据目标选择引入--> + <FrameworkReference Include="Microsoft.AspNetCore.App" /> + </ItemGroup> + + <ItemGroup> + <!--Nuget包引用--> + <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> + <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> + </ItemGroup> + + <ItemGroup> + <!--项目引用--> + <ProjectReference Include="..\xx.csproj" /> + </ItemGroup> + +</Project> +``` +```xml +<!-- 多目标示例--> +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFrameworks>netstandard2.0;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks> + <PackageTags>aspnetcore;authentication;security;basicauth</PackageTags> + <Configurations>Debug;Release;CodeQL</Configurations> + </PropertyGroup> + + <!-- netstandard2.0 版本引入老版本的包(Microsoft.AspNetCore.Authentication等) --> + <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> + <PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.0" /> + <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0" /> + <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0" /> + </ItemGroup> + + <!-- 高版本手动引入共享框架(Microsoft.AspNetCore.App),由共享框架引入模块 --> + <ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'"> + <FrameworkReference Include="Microsoft.AspNetCore.App" /> + </ItemGroup> +</Project> +```