I have a NuGet package that supports 3 different TF
s and should be available for consumers(apps) in Non-sdk
(old csproj
format) and Sdk
(a new one) csproj
files. My nugget also contains native
libraries for Windows, Linux, and mac os.
The only problem I have is related to the processing of native libraries.
I configure it in this way (also there are similar steps that cover non-windows OS
s):
<!--IsWindows is defined in the first steps-->
<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
<Content Include="$(MyLibrariesPathInTheSolution)/nativeWindowsLibrary.dll">
<Pack>true</Pack>
<PackagePath>runtimes/win/native</PackagePath>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
<Content Include="$(MyLibrariesPathInTheSolution)/nativeWindowsLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>nativeWindowsLibrary.dll</Link>
</Content>
</ItemGroup>
the above configuration works well for sdk
projects but doesn't cover non-sdk
s. So, I added one more step into the main csproj
:
<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
<Content Include="MyApp.targets">
<Pack>true</Pack>
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>
where MyApp.targets looks like:
<?xml version="1.0" encoding="utf-8"?>
<!--IsWindows is also defined here, skipped this definition just to reduce the number of lines-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(IsWindows)' == 'true' ">
<Content Include="$(MSBuildThisFileDirectory)../runtimes/win/native/nativeWindowsLibrary.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>nativeWindowsLibrary.dll</Link>
</Content>
</ItemGroup>
</Project>
the above fixes the consumer's issue related to non-sdk
projects, but triggers a problem if a consumer uses xamarin
+ mac OS
because this platform tries to process nativeWindowsLibrary.dll
(MacOS-built
library is processed also but it's expected unlike Windows-built
) during building even though there is the condition on OS = Windows
(which is false
for this case).
So, my main question is there any guide (example) about how to create a NuGet package for the above case where we need to support:
runtimes
)also, are there any suggestions about the provided configuration?
this is a bug in xamarin https://github.com/xamarin/xamarin-macios/issues/10337 related to the mono msbuild issue https://github.com/mono/mono/issues/15569