【发布时间】:2019-02-12 06:43:10
【问题描述】:
我正在尝试使用 this project 为 Python.NET 创建一个多平台包,以 .NET Standard 2.0 为目标。
我设法创建了一个具有以下结构的 NuGet 包:
ref
|- netstandard2.0
|- Python.Runtime.dll
runtimes
|- win
|- lib
|- netstandard2.0
|- Python.Runtime.dll
|- linux-x64
|- ...
这个包可以完美地与基于新的 .csproj 格式 + PackageReferece 的测试应用配合使用,但前提是我以 netcoreappX.X 为目标。在这种情况下,它会将整个 runtimes 文件夹复制到 dotnet publish 上的输出并正常运行。
如果我将TargetFramework 更改为net472,Windows 上的dotnet build 和dotnet publish 都无法从包中复制任何版本的Python.Runtime.dll,从而导致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.
尝试从 Visual Studio 运行时引发相同的异常。
该异常实际上是有道理的,因为我可以看到程序集没有复制到输出目录。
现在的问题是以下哪一项是问题,我该如何解决:
- 我的 .nuget 包缺少一些东西,所以没有为
net472目标拾取任何东西(尽管我希望它只是使用netstandard2.0东西) - 我的测试应用 .csproj 缺少一些东西(也许我需要在 .csproj 中指定所有支持的运行时?)
- 工具根本不支持这样的设置
如果上述问题有解决方案,是否也适用于带有packages.config 的旧式.NET Framework 项目?
【问题讨论】:
标签: .net .net-core nuget .net-standard-2.0 .net-4.7.2