Interop methods with Py_ssize_t works differently in NetCoreApp 2.0 by dmitriyse · Pull Request #531 · pythonnet/pythonnet

Hi, I'm not sure if the best place to comment, but running python setup.py install in this PR, on a Win10 machine with only dotnetcore 2.0 and no VS, it seems to pick msbuild from the .NET framework runtime; here's the output:

(dotnet2) username@host c:\temp\pythonnet
> python setup.py build
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.1.0.
Updating NuGet.exe to 4.3.0.
Update successful.
MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319'.
All packages listed in packages.config are already installed.
Traceback (most recent call last):
  File "setup.py", line 502, in <module>
    zip_safe=False,
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\command\build_ext.py", line 339, in run
    self.build_extensions()
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\command\build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "c:\tools\Anaconda3\envs\dotnet2\lib\distutils\command\build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "setup.py", line 251, in build_extension
    manifest = self._get_manifest(dest_dir)
  File "setup.py", line 269, in _get_manifest
    mt = self._find_msbuild_tool("mt.exe", use_windows_sdk=True)
  File "setup.py", line 367, in _find_msbuild_tool
    raise RuntimeError("{0} could not be found".format(tool))
RuntimeError: mt.exe could not be found

The reason appears to be this line in setup.py.

Trying with DEVTOOLS = 'dotnet', it fails further down because of pkg-config due to that line.

Skipping this part (by commenting the DEVTOOLS === 'dotnet') part, the build succeeds, but the installation is not complete; python -c "import clr" fails now, as there's not clr.pyd.

Alternatively, I used the wheel file from appveyor, which succesfully install everything. However, now, despite the fact that system DLLs can be imported in Python, a simple hello-world library (netstandard2.0) called M22 fails with the following:

> ipython
Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import clr

In [2]: clr.AddReference('System')
Out[2]: <System.Reflection.RuntimeAssembly at 0x23cb30f5e48>

In [3]: from System import DateTime

In [4]: print(DateTime.Now)
28/09/2017 10:22:58

In [5]: m22 = clr.AddReference('M22')

In [6]: [str(a) for a in m22.get_ExportedTypes()]
---------------------------------------------------------------------------
FileNotFoundException                     Traceback (most recent call last)
<ipython-input-6-cf6f2e420cd8> in <module>()
----> 1 [str(a) for a in m22.get_ExportedTypes()]

FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()

All the above is run on a clean Python 3.6 conda environment. This also fails on master. Happy to investigate further, if this an actual problem.

Ps. The above works fine with VS and .NET Framework.