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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Build.BackEnd.Logging;
using Microsoft.Build.Collections;
using Microsoft.Build.Construction;
using Microsoft.Build.Eventing;
using Microsoft.Build.Framework;
using Microsoft.Build.Shared;
using Microsoft.Build.Utilities;
Expand Down Expand Up @@ -35,6 +36,8 @@ public override void ClearCaches()

public override SdkResult ResolveSdk(int submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, string solutionPath, string projectPath, bool interactive, bool isRunningInVisualStudio)
{
MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStart(sdk.Name, solutionPath, projectPath);

SdkResult result;

if (Traits.Instance.EscapeHatches.DisableSdkResolutionCache)
Expand Down Expand Up @@ -66,6 +69,8 @@ public override SdkResult ResolveSdk(int submissionId, SdkReference sdk, Logging
loggingContext.LogWarning(null, new BuildEventFileInfo(sdkReferenceLocation), "ReferencingMultipleVersionsOfTheSameSdk", sdk.Name, result.Version, result.ElementLocation, sdk.Version);
}

MSBuildEventSource.Log.CachedSdkResolverServiceResolveSdkStop(sdk.Name, solutionPath, projectPath, result.Success);

return result;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Build.Eventing;

namespace Microsoft.Build.BackEnd.SdkResolution
{
Expand Down Expand Up @@ -115,7 +116,9 @@ public virtual SdkResult ResolveSdk(int submissionId, SdkReference sdk, LoggingC

try
{
MSBuildEventSource.Log.SdkResolverResolveSdkStart();
result = (SdkResult)sdkResolver.Resolve(sdk, context, resultFactory);
MSBuildEventSource.Log.SdkResolverResolveSdkStop(sdkResolver.Name, sdk.Name, solutionPath, projectPath, result?.Path, result?.Success ?? false);
}
catch (Exception e) when ((e is FileNotFoundException || e is FileLoadException) && sdkResolver.GetType().GetTypeInfo().Name.Equals("NuGetSdkResolver", StringComparison.Ordinal))
{
Expand Down Expand Up @@ -232,8 +235,11 @@ private void Initialize(LoggingContext loggingContext, ElementLocation location)
return;
}

MSBuildEventSource.Log.SdkResolverServiceInitializeStart();
_resolvers = _sdkResolverLoader.LoadResolvers(loggingContext, location);
MSBuildEventSource.Log.SdkResolverServiceInitializeStop(_resolvers.Count);
}

}

private void SetResolverState(int submissionId, SdkResolver resolver, object state)
Expand Down
38 changes: 37 additions & 1 deletion src/Framework/MSBuildEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public void TargetUpToDateStop(int result)
{
WriteEvent(57, result);
}

[Event(58, Keywords = Keywords.All)]
public void CopyUpToDateStart(string path)
{
Expand All @@ -454,6 +454,42 @@ public void WriteLinesToFileUpToDateStop(string fileItemSpec, bool wasUpToDate)
WriteEvent(61, fileItemSpec, wasUpToDate);
}

[Event(62, Keywords = Keywords.All)]
public void SdkResolverServiceInitializeStart()
{
WriteEvent(62);
}

[Event(63, Keywords = Keywords.All)]
public void SdkResolverServiceInitializeStop(int resolverCount)
{
WriteEvent(63, resolverCount);
}

[Event(64, Keywords = Keywords.All)]
public void SdkResolverResolveSdkStart()
{
WriteEvent(64);
}

[Event(65, Keywords = Keywords.All)]
public void SdkResolverResolveSdkStop(string resolverName, string sdkName, string solutionPath, string projectPath, string sdkPath, bool success)
{
WriteEvent(65, resolverName, sdkName, solutionPath, projectPath, sdkPath, success);
}

[Event(66, Keywords = Keywords.All)]
public void CachedSdkResolverServiceResolveSdkStart(string sdkName, string solutionPath, string projectPath)
{
WriteEvent(66, sdkName, solutionPath, projectPath);
}

[Event(67, Keywords = Keywords.All)]
public void CachedSdkResolverServiceResolveSdkStop(string sdkName, string solutionPath, string projectPath, bool success)
{
WriteEvent(67, sdkName, solutionPath, projectPath, success);
}

#endregion
}
}