I was using Visual Studio 2019 on a WPF C# project for a win app. This app was configure with old style not with SDK-Style projects. I wanted to have all DLLs files embedded into the executable so I can just have one single exe file. This is not longer valid with Visual Studio 2022 and the new SDK-Style project. For some reason the same solution doesn't work there.
I tried the same thing I had in my previous project:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="AfterResolveReferences">
    <ItemGroup>
      <EmbeddedResource Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
        <LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
      </EmbeddedResource>
    </ItemGroup>
  </Target>
Now with the VS 2022 and the SDK-Style project I needed to change a lot more thing in the .vcproj file to get the same functionality I have to get the single file application functionality.
The Import tag doesn't work anymore because it says that it is adding the targets anyway so it is duplicated. I found a way to not to use it and have the Target to be at the end of the build phase.
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="echo executing the post build event" />
    <ItemGroup>
      <EmbeddedResource Include="@(ReferenceCopyLocalPaths)"
                        Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
          <LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
      </EmbeddedResource>
    </ItemGroup>
   </Target>
The problem now is that, the embedded stuff is not working for some reason and I cannot find anywhere on the internet a solution for this problem. It is like every one is using the old style method and that's it. Maybe it is not possible anymore.
Here is a post from 14 years ago: Embedding DLLs in a compiled executable
 
     
    