File: Context\ProjectOptions.cs
Web Access
Project: src\src\sdk\src\Dotnet.Watch\Watch\Microsoft.DotNet.HotReload.Watch.csproj (Microsoft.DotNet.HotReload.Watch)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.DotNet.Watch;

internal sealed record ProjectOptions
{
    public required ProjectRepresentation Representation { get; init; }

    /// <summary>
    /// True if the project has been launched by watch in the main iteration loop.
    /// </summary>
    public required bool IsMainProject { get; init; }

    public required string WorkingDirectory { get; init; }

    /// <summary>
    /// Target framework to use to launch the project.
    /// If the project multi-targets and <see cref="TargetFramework"/> is null
    /// the user will be prompted for the framework in interactive mode
    /// or an error is reported in non-interactive mode.
    /// </summary>
    public string? TargetFramework { get; init; }

    /// <summary>
    /// Device identifier to use when launching the project.
    /// If the project supports device selection and <see cref="Device"/> is null
    /// the user will be prompted for a device in interactive mode.
    /// </summary>
    public string? Device { get; init; }

    /// <summary>
    /// RuntimeIdentifier provided by the selected device, if any.
    /// </summary>
    public string? DeviceRuntimeIdentifier { get; init; }

    /// <summary>
    /// No value indicates that no launch profile should be used.
    /// Null value indicates that the default launch profile should be used.
    /// </summary>
    public required Optional<string?> LaunchProfileName { get; init; }

    /// <summary>
    /// Command to use to launch the project.
    /// </summary>
    public required string Command { get; init; }

    /// <summary>
    /// Arguments passed to <see cref="Command"/> to launch to the project.
    /// </summary>
    public required IReadOnlyList<string> CommandArguments { get; init; }

    /// <summary>
    /// Additional environment variables to set to the running process.
    /// </summary>
    public required IReadOnlyList<(string name, string value)> LaunchEnvironmentVariables { get; init; }

    /// <summary>
    /// Returns true if the command executes the code of the target project.
    /// </summary>
    public bool IsCodeExecutionCommand
        => Command is "run" or "test";
}