Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++/CLI projects do not generate .runtimeconfig.json #3889

Open
elinor-fung opened this issue Nov 11, 2019 · 3 comments
Open

C++/CLI projects do not generate .runtimeconfig.json #3889

elinor-fung opened this issue Nov 11, 2019 · 3 comments
Assignees

Comments

@elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Nov 11, 2019

When building a C++/CLI library, a .runtimeconfig.json file is not generated. As a result, these libraries cannot be used from native applications or through p/invokes from managed applications.

Repro:
VS 2019 16.4 Preview 4
.NET Core 3.1.0-preview2

  1. Create a C++/CLI library in Visual Studio
  2. Create either a:
    • native application that calls into the library from (1)
    • managed application that uses DllImport to p/invoke into the library from (1)
  3. Run the application from (2)
    • Failure on using the library because there is no .runtimeconfig.json present

cc @wli3 @nguerrera

@wli3

This comment has been minimized.

Copy link
Contributor

@wli3 wli3 commented Nov 12, 2019

  • Decide if we want to enable generating runtimeconfig by default for C++ library?
  • Fix when asset file is missing, generating runtimeconfig also get disabled
  • enable generate runtimeconfig, enable generate deps.json – Runtime will load files setting in the output directory, however deps.json is still needed when there is transitive dependency like CLI/C++ -> C# -> nuget packages. Try to generate deps.json with only RAR input. If the result is not enough, we would need to enable nuget restore with PackageReference support. That need C++ change.

Note to self:

  • Make sure we still have the right error message when we expect runtimeconfig while it is missing
@wli3

This comment has been minimized.

Copy link
Contributor

@wli3 wli3 commented Nov 13, 2019

Lucky ProjectRuntimeConfigFilePath is based on $(TagetDir)

<ProjectRuntimeConfigFilePath Condition="'$(ProjectRuntimeConfigFilePath)' == ''">$(TargetDir)$(ProjectRuntimeConfigFileName)</ProjectRuntimeConfigFilePath>

There is mismatch in C++ I believe. Due to the following issue, I can only test in a single library. And the output location is correct there.

However, looks like creating a runtime config is much harder since existing code is highly coupled with asset file. I am not sure a short cut of the following is enough.

                RuntimeConfig config = new RuntimeConfig();
                config.RuntimeOptions = new RuntimeOptions();

                    config.RuntimeOptions.Framework = new RuntimeConfigFramework();
                    config.RuntimeOptions.Framework.Name = RuntimeFrameworks[0].GetMetadata("FrameworkName");
                    config.RuntimeOptions.Framework.Version = RuntimeFrameworks[0].GetMetadata("Version");
                    config.RuntimeOptions.Tfm = TargetFramework;
                    config.RuntimeOptions.RollForward = RollForward;

Also, even today, if a C# console app referencing a C# library with EnableDynamicLoading=true, the result output folder will not have the library’s runtimeconfig.json. Is it still useful? @elinor-fung @olgaark

@elinor-fung

This comment has been minimized.

Copy link
Member Author

@elinor-fung elinor-fung commented Nov 13, 2019

C# console app referencing a C# library with EnableDynamicLoading=true, the result output folder will not have the library’s runtimeconfig.json.

The direct reference like that wouldn't need the .runtimeconfig.json (since it wouldn't be using the referenced library as a 'component'). However, I could imagine something like using project references for build order/copying to output (without the direct reference) and expecting everything be copied for use as a separate component. That said, I'm not sure how much doing something like that is supported in general - trying something like that won't work for console apps either, since .runtimeconfig.json and .deps.json don't get copied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.