pythonnet-stub-generator icon indicating copy to clipboard operation
pythonnet-stub-generator copied to clipboard

Documentation improvements

Open mardukbp opened this issue 1 year ago • 2 comments

First of all thank you for writing this awesome tool!

I installed it using .NET 8. When I executed GeneratePythonNetStubs I got the error (abridged):

You must install or update .NET to run this application.

Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: E:\dotnet-sdk-8-x64

Which means that it requires the .NET 6 x64 Runtime. I downloaded it, unpacked it in Downloads and then set the environment variable DOTNET_ROOT to the .NET 6 runtime. GeneratePythonNetStubs then did its magic :)

In order to use the typings in VS Code with the Python extension I added the following to settings.json:

"python.autoComplete.extraPaths": [
    "typings"
]

I think it would be great to provide these two pieces of information in the README so that people can benefit the most from your efforts.

mardukbp avatar Jul 16 '24 21:07 mardukbp

Another tip. In order to automatically generate the typings after publishing the .NET Project with dotnet publish -c Release I added the following to the projects' .csproj file:

<PropertyGroup Condition="'$(Configuration)'=='Release'">
  <DebugSymbols>False</DebugSymbols>
  <DebugType>None</DebugType>
  <PublishDir>..\proj</PublishDir>
</PropertyGroup>

<Target Name="GenerateStubs" AfterTargets="Publish">
  <Exec Command="GeneratePythonNetStubs --dest-path=../../typings --target-dlls=../proj/CalcTest.dll"/>
</Target>

mardukbp avatar Jul 16 '24 21:07 mardukbp

I found a simpler way to execute it with .NET 8:

GeneratePythonNetStubs --roll-forward LatestMajor --dest-path=../../typings --target-dlls=../proj/CalcTest.dll

mardukbp avatar Jul 17 '24 12:07 mardukbp