Good evening, I am trying to integrate .net core 3.0 in my engine as a scripting language. As such I want to be able to kick c# code from my c++ code. I am following the sample code for hosting.
The code, requires a runtimeconfig.json for my c# dll that I want to load and execute at runtime. Unluckily I am unable to generate such file when using dotnet publish.
I have tried to both create a visual studio project which a 3.0 class library and do
dotnet new classlib
And upgrade the project to netcoreapp3.0. Only the deps.json file is generated, not the runtimeconfig.json one.
to repdoruce:
I would expect the see a *.runtimeconfig.json file generated along the *.dll *.pbd *.deps.json
I tried to do both self contained and not, force x64 etc. No luck.
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-rc1-014190
Commit: c4d43f672d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk3.0.100-rc1-014190
Host (useful for support):
Version: 3.0.0-rc1-19456-20
Commit: 8f5d7b1ba4
.NET Core SDKs installed:
2.1.507 [C:Program Filesdotnetsdk]
2.1.508 [C:Program Filesdotnetsdk]
2.1.700 [C:Program Filesdotnetsdk]
2.1.701 [C:Program Filesdotnetsdk]
2.1.800-preview-009696 [C:Program Filesdotnetsdk]
2.1.800 [C:Program Filesdotnetsdk]
2.1.801 [C:Program Filesdotnetsdk]
2.1.802 [C:Program Filesdotnetsdk]
3.0.100-rc1-014190 [C:Program Filesdotnetsdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-rc1.19457.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-rc1-19456-20 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-rc1-19456-20 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
Am I doing anything wrong?
Best regards
A class library is not runnable and as such does not have a runtimeconfig.json. You can create a console app or change your app to be an executable by setting <OutputType>exe</OutputType>.
Thank you your reply actually put me on the right path. What I did not understand was that the dotnet sample was not using an exe, and did not have a Main function, the trick is to add
<EnableDynamicLoading>true</EnableDynamicLoading>
This will properly export the needed runtimeconfig.json.
Since I have you hear, I know is not for this issue but if too out of topic let me know and I will just close the issue or open another one just for this.
The sample does a lot of stuff to try to get the AppHost (used to load the assemblies from c++) package, is there a way to use the dotnet command or similar to do that from command line? I am trying to automate the build (hopefully cmake) to try to get that nuget and the needed headers/lib to link. For now I managed to find the path and hardcoded the path, for example:
C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\3.0.0-rc1-19456-20\runtimes\win-x64\native
Thanks a lot!
Which sample are you referring to?
If all you care about is generating a runtime config, you can set <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> directly. This property is set to true when EnableDynamicLoading is used.
I don't believe there is a command line way to resolve the file you mentioned above.
I solved the issue for the configuration thank you. About the package yeah does not seem to be a solution for now, I think there is a PR/Issue open in one of the dotnet repositories to have the lib and headers in the vkpg. Such that can also be used by cmake if not mistaken. I will be keeping an eye on that. Thanks!
Most helpful comment
Which sample are you referring to?
If all you care about is generating a runtime config, you can set
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>directly. This property is set to true whenEnableDynamicLoadingis used.I don't believe there is a command line way to resolve the file you mentioned above.