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

[API Proposal]: Expose dotnet info by introducing a new hostfxr API #98735

Open
Markliniubility opened this issue Feb 21, 2024 · 4 comments
Open
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-Host
Milestone

Comments

@Markliniubility
Copy link

Background and motivation

dotnet SDK intends to implement a new command dotnet info to replace the original dotnet --info. The detail is specified in dotnet/sdk#33697.

However, to implement this new command, we need to have some information exposed in the corehost, which are:

  • Host,
  • .NET SDKs installed,
  • .NET runtimes installed,
  • Other architectures found,
  • Environment Variables, and
  • global.json file

We may make modification to this file to introduce the new API

struct hostfxr_dotnet_environment_info
{
size_t size;
const char_t* hostfxr_version;
const char_t* hostfxr_commit_hash;
size_t sdk_count;
const struct hostfxr_dotnet_environment_sdk_info* sdks;
size_t framework_count;
const struct hostfxr_dotnet_environment_framework_info* frameworks;
};

API Proposal

SHARED_API int32_t HOSTFXR_CALLTYPE hostfxr_get_dotnet_host_info(
    const pal::char_t* dotnet_root,
    void* reserved,
    hostfxr_get_dotnet_host_info_result_fn result,
    void* result_context)
{}

API Usage

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Auto)]
        internal delegate void hostfxr_get_dotnet_environment_info_result_fn(
            IntPtr info,
            IntPtr result_context);

        [DllImport(Constants.HostFxr, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int hostfxr_get_dotnet_host_info(
            .....);

Alternative Designs

No response

Risks

it would require some versioning magic but that doable (the host has to work against any SDK, so it would have to know to do the old thing for the old SDK and the new thing for the new SDK and unfortunately this can't be done through an API since the host literally runs the SDK as an app). ---- mentioned by @vitek-karas

@Markliniubility Markliniubility added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Feb 21, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Feb 21, 2024
@ghost
Copy link

ghost commented Feb 21, 2024

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Background and motivation

dotnet SDK intends to implement a new command dotnet info to replace the original dotnet --info. The detail is specified in dotnet/sdk#33697.

However, to implement this new command, we need to have some information exposed in the corehost, which are:

  • Host,
  • .NET SDKs installed,
  • .NET runtimes installed,
  • Other architectures found,
  • Environment Variables, and
  • global.json file

We may make modification to this file to introduce the new API

struct hostfxr_dotnet_environment_info
{
size_t size;
const char_t* hostfxr_version;
const char_t* hostfxr_commit_hash;
size_t sdk_count;
const struct hostfxr_dotnet_environment_sdk_info* sdks;
size_t framework_count;
const struct hostfxr_dotnet_environment_framework_info* frameworks;
};

API Proposal

SHARED_API int32_t HOSTFXR_CALLTYPE hostfxr_get_dotnet_host_info(
    const pal::char_t* dotnet_root,
    void* reserved,
    hostfxr_get_dotnet_host_info_result_fn result,
    void* result_context)
{}

API Usage

        [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Auto)]
        internal delegate void hostfxr_get_dotnet_environment_info_result_fn(
            IntPtr info,
            IntPtr result_context);

        [DllImport(Constants.HostFxr, CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
        internal static extern int hostfxr_get_dotnet_host_info(
            .....);

Alternative Designs

No response

Risks

it would require some versioning magic but that doable (the host has to work against any SDK, so it would have to know to do the old thing for the old SDK and the new thing for the new SDK and unfortunately this can't be done through an API since the host literally runs the SDK as an app). ---- mentioned by @vitek-karas

Author: Markliniubility
Assignees: -
Labels:

api-suggestion, area-Host

Milestone: -

@jkotas
Copy link
Member

jkotas commented Feb 21, 2024

However, to implement this new command, we need to have some information exposed in the corehost,

Can SDK gather most or all of this information in managed code on its own?

For example, it does not make sense for the host to return environment variables. The managed dotnet info command can read the environment just fine.

@Markliniubility
Copy link
Author

However, to implement this new command, we need to have some information exposed in the corehost,

Can SDK gather most or all of this information in managed code on its own?

For example, it does not make sense for the host to return environment variables. The managed dotnet info command can read the environment just fine.

Unfortunately, it may be a bit difficult to gather the information within the sdk repo. The current dotnet --info obtain the information from corehost as well. Ref.

void command_line::print_muxer_info(const pal::string_t &dotnet_root, const pal::string_t &global_json_path, bool skip_sdk_info_output)

The corehost will print out the info when there is a command dotnet --info.

@Markliniubility
Copy link
Author

Markliniubility commented Feb 23, 2024

Some earlier discussions for this API proposal: dotnet/sdk#36943

@agocke agocke modified the milestones: 9.0.0, Future Apr 15, 2024
@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-Host
Projects
Status: No status
Development

No branches or pull requests

4 participants
@agocke @jkotas @Markliniubility and others