Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected async Task<int> LaunchWatcherAsync(

try
{
var watcher = new HotReloadDotNetWatcher(context, Console, processLauncherFactory, targetFrameworkSelectionPrompt: null);
var watcher = new HotReloadDotNetWatcher(context, Console, processLauncherFactory, selectionPrompt: null);
await watcher.WatchAsync(cancellationSource.Token);
}
catch (OperationCanceledException) when (shutdownHandler.CancellationToken.IsCancellationRequested)
Expand Down
1 change: 1 addition & 0 deletions src/Dotnet.Watch/Watch/Build/BuildNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ internal static class TargetNames
public const string ResolveReferencedProjectsStaticWebAssets = nameof(ResolveReferencedProjectsStaticWebAssets);
public const string GenerateComputedBuildStaticWebAssets = nameof(GenerateComputedBuildStaticWebAssets);
public const string ReferenceCopyLocalPathsOutputGroup = nameof(ReferenceCopyLocalPathsOutputGroup);
public const string ComputeAvailableDevices = nameof(ComputeAvailableDevices);
}

internal static class ProjectCapability
Expand Down
14 changes: 5 additions & 9 deletions src/Dotnet.Watch/Watch/Build/EvaluationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ internal sealed class EvaluationResult(
LoadedProjectGraph projectGraph,
IReadOnlyDictionary<ProjectInstanceId, ProjectInstance> restoredProjectInstances,
IReadOnlyDictionary<string, FileItem> files,
IReadOnlyDictionary<ProjectInstanceId, StaticWebAssetsManifest> staticWebAssetsManifests,
ProjectBuildManager buildManager)
IReadOnlyDictionary<ProjectInstanceId, StaticWebAssetsManifest> staticWebAssetsManifests)
{
public IReadOnlyDictionary<string, FileItem> Files => files;
public LoadedProjectGraph ProjectGraph => projectGraph;
public ProjectBuildManager BuildManager => buildManager;
public ProjectBuildManager BuildManager => projectGraph.BuildManager;

public readonly FilePathExclusions ItemExclusions
= projectGraph != null ? FilePathExclusions.Create(projectGraph.Graph) : FilePathExclusions.Empty;
Expand Down Expand Up @@ -70,14 +69,11 @@ public static ImmutableDictionary<string, string> GetGlobalBuildProperties(IEnum
var projectLoadingStopwatch = Stopwatch.StartNew();
var stopwatch = Stopwatch.StartNew();

var buildReporter = new BuildReporter(projectGraph.Logger, globalOptions, environmentOptions);
var buildManager = new ProjectBuildManager(projectGraph.ProjectCollection, buildReporter);

if (restore)
{
var restoreRequests = projectGraph.Graph.GraphRoots.Select(node => BuildRequest.Create(node.ProjectInstance, [TargetNames.Restore])).ToArray();

if (await buildManager.BuildAsync(
if (await projectGraph.BuildManager.BuildAsync(
restoreRequests,
onFailure: failedInstance =>
{
Expand Down Expand Up @@ -108,7 +104,7 @@ public static ImmutableDictionary<string, string> GetGlobalBuildProperties(IEnum

var buildRequests = CreateDesignTimeBuildRequests(projectGraph.Graph, mainProjectTargetFramework, environmentOptions.SuppressHandlingStaticWebAssets).ToImmutableArray();

var buildResults = await buildManager.BuildAsync(
var buildResults = await projectGraph.BuildManager.BuildAsync(
buildRequests,
onFailure: failedInstance =>
{
Expand All @@ -132,7 +128,7 @@ public static ImmutableDictionary<string, string> GetGlobalBuildProperties(IEnum

BuildReporter.ReportWatchedFiles(logger, fileItems);

return new EvaluationResult(projectGraph, restoredProjectInstances, fileItems, staticWebAssetManifests, buildManager);
return new EvaluationResult(projectGraph, restoredProjectInstances, fileItems, staticWebAssetManifests);
}

// internal for testing
Expand Down
5 changes: 4 additions & 1 deletion src/Dotnet.Watch/Watch/Build/LoadedProjectGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.DotNet.Watch;

internal sealed class LoadedProjectGraph(ProjectGraph graph, ProjectCollection collection, ILogger logger)
internal sealed class LoadedProjectGraph(ProjectGraph graph, ProjectCollection collection, ILogger logger, GlobalOptions globalOptions, EnvironmentOptions environmentOptions)
{
// full path of proj file to list of nodes representing all target frameworks of the project (excluding outer build nodes):
private readonly IReadOnlyDictionary<string, IReadOnlyList<ProjectGraphNode>> _innerBuildNodes =
Expand All @@ -20,6 +20,9 @@ internal sealed class LoadedProjectGraph(ProjectGraph graph, ProjectCollection c
.Concat(graph.ProjectNodes.Select(p => p.ProjectInstance.FullPath))
.ToHashSet(PathUtilities.OSSpecificPathComparer));

public readonly ProjectBuildManager BuildManager =
new(collection, new BuildReporter(logger, globalOptions, environmentOptions));

public ProjectGraph Graph => graph;
public ILogger Logger => logger;
public ProjectCollection ProjectCollection => collection;
Expand Down
8 changes: 6 additions & 2 deletions src/Dotnet.Watch/Watch/Build/ProjectGraphFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ internal sealed class ProjectGraphFactory(
ImmutableArray<ProjectRepresentation> rootProjects,
string? virtualProjectTargetFramework,
ImmutableDictionary<string, string> buildProperties,
ILogger logger)
ILogger logger,
GlobalOptions globalOptions,
EnvironmentOptions environmentOptions)
{
/// <summary>
/// Reuse <see cref="ProjectCollection"/> with XML element caching to improve performance.
Expand Down Expand Up @@ -60,7 +62,9 @@ private static string GetProductTargetFramework()
var graph = new LoadedProjectGraph(
new ProjectGraph(entryPoints, _collection, (path, globalProperties, collection) => CreateProjectInstance(path, globalProperties, collection, logger), cancellationToken),
_collection,
logger);
logger,
globalOptions,
environmentOptions);

logger.LogDebug("Project graph loaded in {Time}s.", stopwatch.Elapsed.TotalSeconds.ToString("0.0"));
return graph;
Expand Down
12 changes: 12 additions & 0 deletions src/Dotnet.Watch/Watch/Context/ProjectOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ internal sealed record ProjectOptions
/// </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.
Expand Down
Loading
Loading