I have a .net 5 solution that consists of several projects.
Now i had to add the nuget package System.Security.Principal.Windows to one of the projects to be able to do a windows impersonation.
The solution compiles, everything works in the debugger.
But after the publish (to Filesystem) the System.Security.Principal.Windows.dll is missing in (has not been copied to) the publish-folder.
The targetframework is set to net5.0-windows for all projects.
.csproj of the project that will be published:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<RollForward>Major</RollForward>
<StartupObject>My.Special.Service.Program</StartupObject>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<FileVersion>7.0.0.42</FileVersion>
<Version>7.0.0.42</Version>
</PropertyGroup>
...
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="windows" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="5.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Buffering" Version="0.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.17" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="5.0.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
</ItemGroup>
...
</Project>
.csproj of the project that requires system.security.principal.windows:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<RollForward>Major</RollForward>
<RootNamespace>My.Special.Service.ComAccess</RootNamespace>
<AssemblyName>My.Special.Service.ComAccess</AssemblyName>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="windows" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="5.0.0" />
</ItemGroup>
...
</Project>
And this is the publish-profile:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\publish\Release</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net5.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>...</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
What am I missing?