I have a problem with the WinSCP.exe file in my created NuGet package.I reference WinSCP in my project as follows:
<PackageReference Include="WinSCP" version="5.17.10" />
After packing my NuGet package, the winscp.exe is copied to the package in contentFiles. When I reference my package in other projects/NuGet packages, the winscp.exe is also copied into the package. I don't like that, because I want to use the references and download it while package restore (obviously).
But I don't know how I can exclude the .exe from my package.
I tried this:
<PackageReference Include="WinSCP" version="5.17.10" ><PrivateAssets>none</PrivateAssets><IncludeAssets>all</IncludeAssets><ExcludeAssets>contentFiles;build;runtime;native;analyzers</ExcludeAssets></PackageReference>
This works for the first/lowest package, the .exe isn't copied and the reference is set in nuspec.But for higher packages, which reference MY package (with reference WinSCP in nuspec), the .exe file isn't copied.
One workaround is as far as I can see, that I add for each package which is using my first/lowest package, the same reference again:
<PackageReference Include="WinSCP" version="5.17.10" ><PrivateAssets>none</PrivateAssets><IncludeAssets>all</IncludeAssets><ExcludeAssets>contentFiles;build;runtime;native;analyzers</ExcludeAssets></PackageReference>
But I don't think, that is the intended way..
Thanks for any help.