I am trying to make a multiplatform package for Python.NET, targeting .NET Standard 2.0, using this project.
I managed to create a NuGet package with the following structure:
ref
|- netstandard2.0
|- Python.Runtime.dll
runtimes
|- win
|- lib
|- netstandard2.0
|- Python.Runtime.dll
|- linux-x64
|- ...
This package works perfectly with a test app, based on the new .csproj format + PackageReferece
, but only if I target netcoreappX.X
. In that case it copies the whole runtimes
folder to the output on dotnet publish
and runs without a problem.
If I change TargetFramework
to net472
, both dotnet build
and dotnet publish
on Windows fail to copy any version of Python.Runtime.dll from the package, causing FileNotFoundException: Could not load file or assembly 'Python.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
The same exception is raised when trying to run from Visual Studio.
The exception actually makes sense, as I can see the assembly is not copied to the output directory.
Now the question is which of the following is the problem, and how do I fix it:
- my .nuget package lacking something, so nothing is picked up for
net472
target (though I'd expect it simply usingnetstandard2.0
stuff) - my test app .csproj is missing something (maybe I need to specify in the .csproj all the supported runtimes?)
- a setup like this is not supported by tooling at all
If there is a solution to the above problem, would it also work for the old-style .NET Framework projects with packages.config
?