I am stuck at something that might appears to be a simple issue...
I am creating a library project for ASP.NET Core. The library implements a custom AuthenticationHandler so it needs to reference some core ASP.NET Core types.
The project builds cleanly when the csproj is of type "Microsoft.NET.Sdk.Web", the only problem is that the project fails to honor "<GeneratePackageOnBuild>" setting and does not produce a NuGet package.
If I change the project to type "Microsoft.NET.Sdk" and comment out ASP.NET Core-related code, I get the NuGet package created. However, it will have trouble finding the correct ASP.NET Core type information; I get errors like these when ASP.NET Core code is put back:
It appears that most of ASP.NET Core packages are now deprecated and we rely on the SDK to pull in the dependencies. So "Microsoft.NET.Sdk.Web" might be the way to go, but is there a way to force it to honor "<GeneratePackageOnBuild>" setting?
Below is the important portion of my project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>XXXXX.Client</RootNamespace>
<AssemblyName>XXXXX.Client</AssemblyName>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<PlatformTarget>$(Platform)</PlatformTarget>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<CodeAnalysisRuleSet>..\..\..\SingleSignOn.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\SingleSignOn.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>false</IncludeSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<DebugType>embedded</DebugType>
</PropertyGroup>
