Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 18 additions & 18 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,43 +93,43 @@
<Sha>e9dab83bc86ec414b7288d3f8be48a2b14eabb5d</Sha>
<SourceBuild RepoName="fsharp" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset.Framework" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.Net.Compilers.Toolset.Framework" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.13.0-2.24558.12">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.13.0-2.24573.1">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>c0b2f366d0fb54cf49040a82f0d044bb959a9e73</Sha>
<Sha>235c3b8625197dfdcc0c3b13186d104f362df2e8</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="9.0.0-rtm.24529.3">
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-aspnetcore</Uri>
Expand Down
16 changes: 8 additions & 8 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/roslyn -->
<MicrosoftNetCompilersToolsetVersion>4.13.0-2.24558.12</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetFrameworkPackageVersion>4.13.0-2.24558.12</MicrosoftNetCompilersToolsetFrameworkPackageVersion>
<MicrosoftCodeAnalysisPackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.13.0-2.24558.12</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftNetCompilersToolsetVersion>4.13.0-2.24573.1</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetFrameworkPackageVersion>4.13.0-2.24573.1</MicrosoftNetCompilersToolsetFrameworkPackageVersion>
<MicrosoftCodeAnalysisPackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisCSharpCodeStylePackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.13.0-2.24573.1</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/aspnet/AspNetCore -->
Expand Down
31 changes: 20 additions & 11 deletions src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async ValueTask TerminateNonRootProcessesAndDispose(CancellationToken can
Dispose();
}

public ValueTask RestartSessionAsync(ImmutableDictionary<ProjectId, string> projectsToBeRebuilt, CancellationToken cancellationToken)
public void DiscardProjectBaselines(ImmutableDictionary<ProjectId, string> projectsToBeRebuilt, CancellationToken cancellationToken)
{
// Remove previous updates to all modules that were affected by rude edits.
// All running projects that statically reference these modules have been terminated.
Expand All @@ -85,9 +85,13 @@ public ValueTask RestartSessionAsync(ImmutableDictionary<ProjectId, string> proj
_previousUpdates = _previousUpdates.RemoveAll(update => projectsToBeRebuilt.ContainsKey(update.ProjectId));
}

_hotReloadService.EndSession();
_reporter.Report(MessageDescriptor.HotReloadSessionEnded);
return StartSessionAsync(cancellationToken);
_hotReloadService.UpdateBaselines(Workspace.CurrentSolution, projectsToBeRebuilt.Keys.ToImmutableArray());
}

public void UpdateProjectBaselines(ImmutableDictionary<ProjectId, string> projectsToBeRebuilt, CancellationToken cancellationToken)
{
_hotReloadService.UpdateBaselines(Workspace.CurrentSolution, projectsToBeRebuilt.Keys.ToImmutableArray());
_reporter.Report(MessageDescriptor.ProjectBaselinesUpdated);
}

public async ValueTask StartSessionAsync(CancellationToken cancellationToken)
Expand Down Expand Up @@ -275,14 +279,19 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
}

public async ValueTask<(ImmutableDictionary<ProjectId, string> projectsToRebuild, ImmutableArray<RunningProject> terminatedProjects)> HandleFileChangesAsync(
Func<IEnumerable<Project>, CancellationToken, Task> restartPrompt,
Func<IEnumerable<string>, CancellationToken, Task> restartPrompt,
CancellationToken cancellationToken)
{
var currentSolution = Workspace.CurrentSolution;
var runningProjects = _runningProjects;

var updates = await _hotReloadService.GetUpdatesAsync(currentSolution, isRunningProject: p => runningProjects.ContainsKey(p.FilePath!), cancellationToken);
var anyProcessNeedsRestart = updates.ProjectsToRestart.Count > 0;
var runningProjectIds = currentSolution.Projects
.Where(project => project.FilePath != null && runningProjects.ContainsKey(project.FilePath))
.Select(project => project.Id)
.ToImmutableHashSet();

var updates = await _hotReloadService.GetUpdatesAsync(currentSolution, runningProjectIds, cancellationToken);
var anyProcessNeedsRestart = !updates.ProjectIdsToRestart.IsEmpty;

await DisplayResultsAsync(updates, cancellationToken);

Expand All @@ -300,13 +309,13 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
return (ImmutableDictionary<ProjectId, string>.Empty, []);
}

await restartPrompt.Invoke(updates.ProjectsToRestart, cancellationToken);
await restartPrompt.Invoke(updates.ProjectIdsToRestart.Select(id => currentSolution.GetProject(id)!.Name), cancellationToken);

// Terminate all tracked processes that need to be restarted,
// except for the root process, which will terminate later on.
var terminatedProjects = await TerminateNonRootProcessesAsync(updates.ProjectsToRestart.Select(p => p.FilePath!), cancellationToken);
var terminatedProjects = await TerminateNonRootProcessesAsync(updates.ProjectIdsToRestart.Select(id => currentSolution.GetProject(id)!.FilePath!), cancellationToken);

return (updates.ProjectsToRebuild.ToImmutableDictionary(keySelector: p => p.Id, elementSelector: p => p.FilePath!), terminatedProjects);
return (updates.ProjectIdsToRebuild.ToImmutableDictionary(keySelector: id => id, elementSelector: id => currentSolution.GetProject(id)!.FilePath!), terminatedProjects);
}

Debug.Assert(updates.Status == ModuleUpdateStatus.Ready);
Expand Down Expand Up @@ -351,7 +360,7 @@ await ForEachProjectAsync(projectsToUpdate, async (runningProject, cancellationT

private async ValueTask DisplayResultsAsync(WatchHotReloadService.Updates updates, CancellationToken cancellationToken)
{
var anyProcessNeedsRestart = updates.ProjectsToRestart.Count > 0;
var anyProcessNeedsRestart = !updates.ProjectIdsToRestart.IsEmpty;

switch (updates.Status)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ private async Task<bool> ReceiveApplyUpdateResult(CancellationToken cancellation
var status = ArrayPool<byte>.Shared.Rent(1);
try
{
var statusBytesRead = await _pipe.ReadAsync(status, cancellationToken);
var statusBytesRead = await _pipe.ReadAsync(status, offset: 0, count: 1, cancellationToken);
if (statusBytesRead != 1 || status[0] != UpdatePayload.ApplySuccessValue)
{
Reporter.Error($"Change failed to apply (error code: '{BitConverter.ToString(status, 0, statusBytesRead)}'). Further changes won't be applied to this process.");
var message = (statusBytesRead == 0) ? "received no data" : $"received status 0x{status[0]:x2}";
Reporter.Error($"Change failed to apply ({message}). Further changes won't be applied to this process.");
return false;
}

Expand Down
17 changes: 10 additions & 7 deletions src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void FileChangedCallback(string path, ChangeKind kind)

HotReloadEventSource.Log.HotReloadStart(HotReloadEventSource.StartType.CompilationHandler);

var (projectsToRebuild, projectsToRestart) = await compilationHandler.HandleFileChangesAsync(restartPrompt: async (projects, cancellationToken) =>
var (projectsToRebuild, projectsToRestart) = await compilationHandler.HandleFileChangesAsync(restartPrompt: async (projectNames, cancellationToken) =>
{
if (_rudeEditRestartPrompt != null)
{
Expand All @@ -271,9 +271,9 @@ void FileChangedCallback(string path, ChangeKind kind)
{
Context.Reporter.Output("Affected projects:");

foreach (var project in projects.OrderBy(p => p.Name))
foreach (var projectName in projectNames.OrderBy(n => n))
{
Context.Reporter.Output(" " + project.Name);
Context.Reporter.Output(" " + projectName);
}

question = "Do you want to restart these projects?";
Expand All @@ -289,9 +289,9 @@ void FileChangedCallback(string path, ChangeKind kind)
{
Context.Reporter.Verbose("Restarting without prompt since dotnet-watch is running in non-interactive mode.");

foreach (var project in projects)
foreach (var projectName in projectNames)
{
Context.Reporter.Verbose($" Project to restart: '{project.Name}'");
Context.Reporter.Verbose($" Project to restart: '{projectName}'");
}
}
}, iterationCancellationToken);
Expand All @@ -312,6 +312,9 @@ void FileChangedCallback(string path, ChangeKind kind)

if (projectsToRebuild.Count > 0)
{
// Discard baselines before build.
compilationHandler.DiscardProjectBaselines(projectsToRebuild, iterationCancellationToken);

while (true)
{
iterationCancellationToken.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -347,8 +350,8 @@ void FileChangedCallback(string path, ChangeKind kind)
// Apply them to the workspace.
_ = await CaptureChangedFilesSnapshot(projectsToRebuild);

// Restart session to capture new baseline that reflects the changes to the restarted projects.
await compilationHandler.RestartSessionAsync(projectsToRebuild, iterationCancellationToken);
// Update project baselines to reflect changes to the restarted projects.
compilationHandler.UpdateProjectBaselines(projectsToRebuild, iterationCancellationToken);
}

if (projectsToRestart is not [])
Expand Down
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/IReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public bool TryGetMessage(string? prefix, object?[] args, [NotNullWhen(true)] ou
// predefined messages used for testing:
public static readonly MessageDescriptor HotReloadSessionStarting = new(Format: null, Emoji: null, MessageSeverity.None, s_id++);
public static readonly MessageDescriptor HotReloadSessionStarted = new("Hot reload session started.", "🔥", MessageSeverity.Verbose, s_id++);
public static readonly MessageDescriptor HotReloadSessionEnded = new("Hot reload session ended.", "🔥", MessageSeverity.Verbose, s_id++);
public static readonly MessageDescriptor ProjectBaselinesUpdated = new("Project baselines updated.", "🔥", MessageSeverity.Verbose, s_id++);
public static readonly MessageDescriptor FixBuildError = new("Fix the error to continue or press Ctrl+C to exit.", "⌚", MessageSeverity.Warning, s_id++);
public static readonly MessageDescriptor WaitingForChanges = new("Waiting for changes", "⌚", MessageSeverity.Verbose, s_id++);
public static readonly MessageDescriptor LaunchedProcess = new("Launched '{0}' with arguments '{1}': process id {2}", "🚀", MessageSeverity.Verbose, s_id++);
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.NET.Build.Tests/ArtifactsOutputPathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void ItUsesArtifactsOutputPathForBuild()
}
}

[Fact]
[Fact(Skip = "https://github.com/dotnet/sdk/issues/45057")]
public void ItUsesArtifactsOutputPathForPublish()
{
var (testProjects, testAsset) = GetTestProjects();
Expand Down
24 changes: 17 additions & 7 deletions test/Microsoft.NET.TestFramework/Commands/TestCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
Expand Down Expand Up @@ -120,19 +120,29 @@ private static bool SuccessOrNotTransientRestoreError(CommandResult result)

public virtual CommandResult Execute(IEnumerable<string> args)
{
var command = CreateCommandSpec(args)
var spec = CreateCommandSpec(args);

var command = spec
.ToCommand(_doNotEscapeArguments)
.CaptureStdOut()
.CaptureStdErr();

if (CommandOutputHandler != null)
command.OnOutputLine(line =>
{
command.OnOutputLine(CommandOutputHandler);
}
Log.WriteLine($"》{line}");
CommandOutputHandler?.Invoke(line);
});

var result = ((Command)command).Execute(ProcessStartedHandler);
command.OnErrorLine(line =>
{
Log.WriteLine($"❌{line}");
});

var display = $"dotnet {string.Join(" ", spec.Arguments)}";

LogCommandResult(Log, result);
Log.WriteLine($"Executing '{display}':");
var result = ((Command)command).Execute(ProcessStartedHandler);
Log.WriteLine($"Command '{display}' exited with exit code {result.ExitCode}.");

return result;
}
Expand Down
Loading