Skip to content

Commit 00c5249

Browse files
Backflow from https://github.com/dotnet/dotnet / 6f4c060 build 289866
[[ commit created by automation ]]
1 parent 6fa8d44 commit 00c5249

File tree

9 files changed

+126
-20
lines changed

9 files changed

+126
-20
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
3838
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
3939
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion)" />
40+
<PackageVersion Include="Microsoft.CodeAnalysis.ExternalAccess.HotReload" Version="$(MicrosoftCodeAnalysisExternalAccessHotReloadPackageVersion)" />
4041

4142
<!-- roslyn-sdk dependencies-->
4243
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />

eng/Publishing.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
<Artifact Remove="@(MsiPackages)" />
4444
</ItemGroup>
4545

46+
<ItemGroup Condition="'$(PublishingWorkloadMsiInternal)' == 'true'">
47+
<Artifact Update="$(ArtifactsShippingPackagesDir)*.Msi.*.nupkg" Visibility="Internal" />
48+
</ItemGroup>
49+
4650
<Target Name="GetNonStableProductVersion">
4751
<!-- Retrieve the non-stable product version. -->
4852
<MSBuild Projects="$(RepoRoot)src\Layout\redist\redist.csproj"

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
At usage sites, either we use MicrosoftBuildMinimumVersion, or MicrosoftBuildVersion in source-only modes.
113113
114114
Additionally, set the MinimumVSVersion for the installer UI that's required for targeting NetCurrent -->
115-
<MicrosoftBuildMinimumVersion Condition="'$(DotNetBuildSourceOnly)' != 'true'">17.14.8</MicrosoftBuildMinimumVersion>
115+
<MicrosoftBuildMinimumVersion Condition="'$(DotNetBuildSourceOnly)' != 'true'">17.14.28</MicrosoftBuildMinimumVersion>
116116
<MinimumVSVersion>18.0</MinimumVSVersion>
117117
</PropertyGroup>
118118
<PropertyGroup>
@@ -126,7 +126,7 @@
126126
</PropertyGroup>
127127
<PropertyGroup Label="Manually updated">
128128
<!-- Dependencies from https://github.com/microsoft/MSBuildLocator -->
129-
<MicrosoftBuildLocatorPackageVersion>1.8.1</MicrosoftBuildLocatorPackageVersion>
129+
<MicrosoftBuildLocatorPackageVersion>1.10.2</MicrosoftBuildLocatorPackageVersion>
130130
<MicrosoftCodeAnalysisCSharpAnalyzerPinnedVersionPackageVersion>4.0.1</MicrosoftCodeAnalysisCSharpAnalyzerPinnedVersionPackageVersion>
131131
</PropertyGroup>
132132
<!-- Get .NET Framework reference assemblies from NuGet packages -->

src/BuiltInTools/DotNetDeltaApplier/Microsoft.Extensions.DotNetDeltaApplier.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
-->
99
<TargetFrameworks>net6.0;net10.0</TargetFrameworks>
1010
<StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
11+
12+
<DisableTransitiveFrameworkReferenceDownloads Condition="'$(DotNetBuildSourceOnly)' == 'true'">true</DisableTransitiveFrameworkReferenceDownloads>
1113
</PropertyGroup>
1214

1315
<!-- Reference 6.0.0 targeting packs in Source Build -->

src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.Build.Graph;
77
using Microsoft.CodeAnalysis;
88
using Microsoft.CodeAnalysis.CSharp;
9-
using Microsoft.CodeAnalysis.ExternalAccess.Watch.Api;
9+
using Microsoft.CodeAnalysis.ExternalAccess.HotReload.Api;
1010
using Microsoft.DotNet.HotReload;
1111
using Microsoft.Extensions.Logging;
1212

@@ -16,7 +16,7 @@ internal sealed class CompilationHandler : IDisposable
1616
{
1717
public readonly IncrementalMSBuildWorkspace Workspace;
1818
private readonly ILogger _logger;
19-
private readonly WatchHotReloadService _hotReloadService;
19+
private readonly HotReloadService _hotReloadService;
2020
private readonly ProcessRunner _processRunner;
2121

2222
/// <summary>
@@ -35,7 +35,7 @@ internal sealed class CompilationHandler : IDisposable
3535
/// <summary>
3636
/// All updates that were attempted. Includes updates whose application failed.
3737
/// </summary>
38-
private ImmutableList<WatchHotReloadService.Update> _previousUpdates = [];
38+
private ImmutableList<HotReloadService.Update> _previousUpdates = [];
3939

4040
private bool _isDisposed;
4141

@@ -44,7 +44,7 @@ public CompilationHandler(ILogger logger, ProcessRunner processRunner)
4444
_logger = logger;
4545
_processRunner = processRunner;
4646
Workspace = new IncrementalMSBuildWorkspace(logger);
47-
_hotReloadService = new WatchHotReloadService(Workspace.CurrentSolution.Services, () => ValueTask.FromResult(GetAggregateCapabilities()));
47+
_hotReloadService = new HotReloadService(Workspace.CurrentSolution.Services, () => ValueTask.FromResult(GetAggregateCapabilities()));
4848
}
4949

5050
public void Dispose()
@@ -299,7 +299,7 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
299299
}
300300

301301
public async ValueTask<(
302-
ImmutableArray<WatchHotReloadService.Update> projectUpdates,
302+
ImmutableArray<HotReloadService.Update> projectUpdates,
303303
ImmutableArray<string> projectsToRebuild,
304304
ImmutableArray<string> projectsToRedeploy,
305305
ImmutableArray<RunningProject> projectsToRestart)> HandleManagedCodeChangesAsync(
@@ -315,14 +315,14 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
315315
let runningProject = GetCorrespondingRunningProject(project, runningProjects)
316316
where runningProject != null
317317
let autoRestartProject = autoRestart || runningProject.ProjectNode.IsAutoRestartEnabled()
318-
select (project.Id, info: new WatchHotReloadService.RunningProjectInfo() { RestartWhenChangesHaveNoEffect = autoRestartProject }))
318+
select (project.Id, info: new HotReloadService.RunningProjectInfo() { RestartWhenChangesHaveNoEffect = autoRestartProject }))
319319
.ToImmutableDictionary(e => e.Id, e => e.info);
320320

321321
var updates = await _hotReloadService.GetUpdatesAsync(currentSolution, runningProjectInfos, cancellationToken);
322322

323323
await DisplayResultsAsync(updates, runningProjectInfos, cancellationToken);
324324

325-
if (updates.Status is WatchHotReloadService.Status.NoChangesToApply or WatchHotReloadService.Status.Blocked)
325+
if (updates.Status is HotReloadService.Status.NoChangesToApply or HotReloadService.Status.Blocked)
326326
{
327327
// If Hot Reload is blocked (due to compilation error) we ignore the current
328328
// changes and await the next file change.
@@ -364,7 +364,7 @@ private static void PrepareCompilations(Solution solution, string projectPath, C
364364
return (updates.ProjectUpdates, projectsToRebuild, projectsToRedeploy, projectsToRestart);
365365
}
366366

367-
public async ValueTask ApplyUpdatesAsync(ImmutableArray<WatchHotReloadService.Update> updates, CancellationToken cancellationToken)
367+
public async ValueTask ApplyUpdatesAsync(ImmutableArray<HotReloadService.Update> updates, CancellationToken cancellationToken)
368368
{
369369
Debug.Assert(!updates.IsEmpty);
370370

@@ -403,7 +403,7 @@ await ForEachProjectAsync(projectsToUpdate, async (runningProject, cancellationT
403403
}
404404

405405
// msbuild workspace doesn't set TFM if the project is not multi-targeted
406-
var tfm = WatchHotReloadService.GetTargetFramework(project);
406+
var tfm = HotReloadService.GetTargetFramework(project);
407407
if (tfm == null)
408408
{
409409
return projectsWithPath[0];
@@ -412,18 +412,18 @@ await ForEachProjectAsync(projectsToUpdate, async (runningProject, cancellationT
412412
return projectsWithPath.SingleOrDefault(p => string.Equals(p.ProjectNode.GetTargetFramework(), tfm, StringComparison.OrdinalIgnoreCase));
413413
}
414414

415-
private async ValueTask DisplayResultsAsync(WatchHotReloadService.Updates2 updates, ImmutableDictionary<ProjectId, WatchHotReloadService.RunningProjectInfo> runningProjectInfos, CancellationToken cancellationToken)
415+
private async ValueTask DisplayResultsAsync(HotReloadService.Updates updates, ImmutableDictionary<ProjectId, HotReloadService.RunningProjectInfo> runningProjectInfos, CancellationToken cancellationToken)
416416
{
417417
switch (updates.Status)
418418
{
419-
case WatchHotReloadService.Status.ReadyToApply:
419+
case HotReloadService.Status.ReadyToApply:
420420
break;
421421

422-
case WatchHotReloadService.Status.NoChangesToApply:
422+
case HotReloadService.Status.NoChangesToApply:
423423
_logger.Log(MessageDescriptor.NoCSharpChangesToApply);
424424
break;
425425

426-
case WatchHotReloadService.Status.Blocked:
426+
case HotReloadService.Status.Blocked:
427427
_logger.Log(MessageDescriptor.UnableToApplyChanges);
428428
break;
429429

@@ -451,7 +451,7 @@ await ForEachProjectAsync(
451451

452452
void ReportCompilationDiagnostics(DiagnosticSeverity severity)
453453
{
454-
foreach (var diagnostic in updates.CompilationDiagnostics)
454+
foreach (var diagnostic in updates.PersistentDiagnostics)
455455
{
456456
if (diagnostic.Id == "CS8002")
457457
{
@@ -492,7 +492,7 @@ void ReportRudeEdits()
492492
.Where(p => !updates.ProjectsToRestart.ContainsKey(p))
493493
.ToHashSet();
494494

495-
foreach (var (projectId, diagnostics) in updates.RudeEdits)
495+
foreach (var (projectId, diagnostics) in updates.TransientDiagnostics)
496496
{
497497
foreach (var diagnostic in diagnostics)
498498
{
@@ -689,7 +689,7 @@ public bool TryGetRunningProject(string projectPath, out ImmutableArray<RunningP
689689
private static Task ForEachProjectAsync(ImmutableDictionary<string, ImmutableArray<RunningProject>> projects, Func<RunningProject, CancellationToken, Task> action, CancellationToken cancellationToken)
690690
=> Task.WhenAll(projects.SelectMany(entry => entry.Value).Select(project => action(project, cancellationToken))).WaitAsync(cancellationToken);
691691

692-
private static ImmutableArray<HotReloadManagedCodeUpdate> ToManagedCodeUpdates(ImmutableArray<WatchHotReloadService.Update> updates)
692+
private static ImmutableArray<HotReloadManagedCodeUpdate> ToManagedCodeUpdates(ImmutableArray<HotReloadService.Update> updates)
693693
=> [.. updates.Select(update => new HotReloadManagedCodeUpdate(update.ModuleId, update.MetadataDelta, update.ILDelta, update.PdbDelta, update.UpdatedTypes, update.RequiredCapabilities))];
694694
}
695695
}

src/BuiltInTools/dotnet-watch/HotReload/IncrementalMSBuildWorkspace.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Immutable;
55
using System.Diagnostics;
66
using Microsoft.CodeAnalysis;
7-
using Microsoft.CodeAnalysis.ExternalAccess.Watch.Api;
7+
using Microsoft.CodeAnalysis.ExternalAccess.HotReload.Api;
88
using Microsoft.CodeAnalysis.Host.Mef;
99
using Microsoft.CodeAnalysis.MSBuild;
1010
using Microsoft.CodeAnalysis.Text;
@@ -76,7 +76,7 @@ public async Task UpdateProjectConeAsync(string rootProjectPath, CancellationTok
7676
continue;
7777
}
7878

79-
newSolution = WatchHotReloadService.WithProjectInfo(newSolution, ProjectInfo.Create(
79+
newSolution = HotReloadService.WithProjectInfo(newSolution, ProjectInfo.Create(
8080
oldProjectId,
8181
newProjectInfo.Version,
8282
newProjectInfo.Name,

src/BuiltInTools/dotnet-watch/dotnet-watch.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<PackageReference Include="Microsoft.Build.Locator" />
4444
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
4545
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
46+
<PackageReference Include="Microsoft.CodeAnalysis.ExternalAccess.HotReload" />
4647
<PackageReference Include="Microsoft.NET.StringTools" ExcludeAssets="runtime" PrivateAssets="All" />
4748

4849
<Compile Include="$(RepoRoot)src\Common\PathUtilities.cs" LinkBase="Common" />

src/RazorSdk/Tool/GenerateCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#nullable disable
55

66
using System.Diagnostics;
7+
using System.Threading;
78
using Microsoft.AspNetCore.Razor.Language;
89
using Microsoft.CodeAnalysis.CSharp;
910
using Microsoft.NET.Sdk.Razor.Tool.CommandLineUtils;
@@ -433,6 +434,7 @@ private class StaticTagHelperFeature : RazorEngineFeatureBase, ITagHelperFeature
433434
{
434435
public IReadOnlyList<TagHelperDescriptor> TagHelpers { get; set; }
435436

437+
public IReadOnlyList<TagHelperDescriptor> GetDescriptors(CancellationToken cancellationToken) => TagHelpers;
436438
public IReadOnlyList<TagHelperDescriptor> GetDescriptors() => TagHelpers;
437439
}
438440
}

test/dotnet.Tests/CommandTests/MSBuild/GivenMSBuildLogger.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,101 @@ public void ItIgnoresNonIntegerPropertiesDuringAggregation()
214214
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty");
215215
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty2");
216216
}
217+
218+
[Fact]
219+
public void ItAggregatesEvents()
220+
{
221+
var fakeTelemetry = new FakeTelemetry();
222+
fakeTelemetry.Enabled = true;
223+
var logger = new MSBuildLogger(fakeTelemetry);
224+
225+
var event1 = new TelemetryEventArgs
226+
{
227+
EventName = MSBuildLogger.TaskFactoryTelemetryAggregatedEventName,
228+
Properties = new Dictionary<string, string>
229+
{
230+
{ "AssemblyTaskFactoryTasksExecutedCount", "2" },
231+
{ "RoslynCodeTaskFactoryTasksExecutedCount", "1" }
232+
}
233+
};
234+
235+
var event2 = new TelemetryEventArgs
236+
{
237+
EventName = MSBuildLogger.TaskFactoryTelemetryAggregatedEventName,
238+
Properties = new Dictionary<string, string>
239+
{
240+
{ "AssemblyTaskFactoryTasksExecutedCount", "3" },
241+
{ "CustomTaskFactoryTasksExecutedCount", "2" }
242+
}
243+
};
244+
245+
var event3 = new TelemetryEventArgs
246+
{
247+
EventName = MSBuildLogger.TasksTelemetryAggregatedEventName,
248+
Properties = new Dictionary<string, string>
249+
{
250+
{ "TasksExecutedCount", "3" },
251+
{ "TaskHostTasksExecutedCount", "2" }
252+
}
253+
};
254+
255+
var event4 = new TelemetryEventArgs
256+
{
257+
EventName = MSBuildLogger.TasksTelemetryAggregatedEventName,
258+
Properties = new Dictionary<string, string>
259+
{
260+
{ "TasksExecutedCount", "5" }
261+
}
262+
};
263+
264+
logger.AggregateEvent(event1);
265+
logger.AggregateEvent(event2);
266+
logger.AggregateEvent(event3);
267+
logger.AggregateEvent(event4);
268+
269+
logger.SendAggregatedEventsOnBuildFinished(fakeTelemetry);
270+
271+
fakeTelemetry.LogEntries.Should().HaveCount(2);
272+
273+
var taskFactoryEntry = fakeTelemetry.LogEntries.FirstOrDefault(e => e.EventName == $"msbuild/{MSBuildLogger.TaskFactoryTelemetryAggregatedEventName}");
274+
taskFactoryEntry.Should().NotBeNull();
275+
taskFactoryEntry.Properties["AssemblyTaskFactoryTasksExecutedCount"].Should().Be("5"); // 2 + 3
276+
taskFactoryEntry.Properties["RoslynCodeTaskFactoryTasksExecutedCount"].Should().Be("1"); // 1 + 0
277+
taskFactoryEntry.Properties["CustomTaskFactoryTasksExecutedCount"].Should().Be("2"); // 0 + 2
278+
279+
var tasksEntry = fakeTelemetry.LogEntries.FirstOrDefault(e => e.EventName == $"msbuild/{MSBuildLogger.TasksTelemetryAggregatedEventName}");
280+
tasksEntry.Should().NotBeNull();
281+
tasksEntry.Properties["TasksExecutedCount"].Should().Be("8"); // 3 + 5
282+
tasksEntry.Properties["TaskHostTasksExecutedCount"].Should().Be("2"); // 2 + 0
283+
}
284+
285+
[Fact]
286+
public void ItIgnoresNonIntegerPropertiesDuringAggregation()
287+
{
288+
var fakeTelemetry = new FakeTelemetry();
289+
fakeTelemetry.Enabled = true;
290+
var logger = new MSBuildLogger(fakeTelemetry);
291+
292+
var eventArgs = new TelemetryEventArgs
293+
{
294+
EventName = MSBuildLogger.TaskFactoryTelemetryAggregatedEventName,
295+
Properties = new Dictionary<string, string>
296+
{
297+
{ "AssemblyTaskFactoryTasksExecutedCount", "3" },
298+
{ "InvalidProperty", "not-a-number" },
299+
{ "InvalidProperty2", "1.234" },
300+
}
301+
};
302+
303+
logger.AggregateEvent(eventArgs);
304+
305+
logger.SendAggregatedEventsOnBuildFinished(fakeTelemetry);
306+
307+
fakeTelemetry.LogEntry.Should().NotBeNull();
308+
fakeTelemetry.LogEntry.EventName.Should().Be($"msbuild/{MSBuildLogger.TaskFactoryTelemetryAggregatedEventName}");
309+
fakeTelemetry.LogEntry.Properties["AssemblyTaskFactoryTasksExecutedCount"].Should().Be("3");
310+
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty");
311+
fakeTelemetry.LogEntry.Properties.Should().NotContainKey("InvalidProperty2");
312+
}
217313
}
218314
}

0 commit comments

Comments
 (0)