-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use ProjectGraph for DTB #49589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Use ProjectGraph for DTB #49589
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
738b50f
Use ProjectGraph for DTB
tmat f605bf6
Move TargetExtension to TestProject type
tmat 760d32a
Fix TestProject references
tmat c2f6078
C# and VB
tmat b3f7e69
Fixes
tmat fb7828c
Build before DTB
tmat cab7026
Deep copy
tmat d64d214
Enable in-proc msbuild tests
tmat 263ff2b
Use polling file watcher in all tests.
tmat 8fdf2f3
Workaround for incorrect ProjectGraph caching
tmat f4669b1
Remove msbuild reference from test sdk
tmat 055d689
Fix line
tmat f6243c1
Binlog path
tmat 3a63d97
Improve binlog
tmat 6787536
Rename
tmat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// 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 static class PropertyNames | ||
{ | ||
public const string TargetFramework = nameof(TargetFramework); | ||
public const string TargetFrameworkIdentifier = nameof(TargetFrameworkIdentifier); | ||
public const string TargetPath = nameof(TargetPath); | ||
public const string EnableDefaultItems = nameof(EnableDefaultItems); | ||
public const string TargetFrameworks = nameof(TargetFrameworks); | ||
public const string WebAssemblyHotReloadCapabilities = nameof(WebAssemblyHotReloadCapabilities); | ||
public const string TargetFrameworkVersion = nameof(TargetFrameworkVersion); | ||
public const string TargetName = nameof(TargetName); | ||
public const string IntermediateOutputPath = nameof(IntermediateOutputPath); | ||
public const string HotReloadAutoRestart = nameof(HotReloadAutoRestart); | ||
public const string DefaultItemExcludes = nameof(DefaultItemExcludes); | ||
public const string CustomCollectWatchItems = nameof(CustomCollectWatchItems); | ||
public const string UsingMicrosoftNETSdkRazor = nameof(UsingMicrosoftNETSdkRazor); | ||
public const string DotNetWatchContentFiles = nameof(DotNetWatchContentFiles); | ||
public const string DotNetWatchBuild = nameof(DotNetWatchBuild); | ||
public const string DesignTimeBuild = nameof(DesignTimeBuild); | ||
public const string SkipCompilerExecution = nameof(SkipCompilerExecution); | ||
public const string ProvideCommandLineArgs = nameof(ProvideCommandLineArgs); | ||
} | ||
|
||
internal static class ItemNames | ||
{ | ||
public const string Watch = nameof(Watch); | ||
public const string AdditionalFiles = nameof(AdditionalFiles); | ||
public const string Compile = nameof(Compile); | ||
public const string Content = nameof(Content); | ||
public const string ProjectCapability = nameof(ProjectCapability); | ||
} | ||
|
||
internal static class MetadataNames | ||
{ | ||
public const string Watch = nameof(Watch); | ||
} | ||
|
||
internal static class TargetNames | ||
{ | ||
public const string Compile = nameof(Compile); | ||
public const string Restore = nameof(Restore); | ||
public const string GenerateComputedBuildStaticWebAssets = nameof(GenerateComputedBuildStaticWebAssets); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Logging; | ||
|
||
namespace Microsoft.DotNet.Watch; | ||
|
||
internal sealed class BuildReporter(IReporter reporter, EnvironmentOptions environmentOptions) | ||
{ | ||
public IReporter Reporter => reporter; | ||
public EnvironmentOptions EnvironmentOptions => environmentOptions; | ||
|
||
public Loggers GetLoggers(string projectPath, string operationName) | ||
=> new(reporter, environmentOptions.GetTestBinLogPath(projectPath, operationName)); | ||
|
||
public void ReportWatchedFiles(Dictionary<string, FileItem> fileItems) | ||
{ | ||
reporter.Verbose($"Watching {fileItems.Count} file(s) for changes"); | ||
|
||
if (environmentOptions.TestFlags.HasFlag(TestFlags.RunningAsTest)) | ||
{ | ||
foreach (var file in fileItems.Values) | ||
{ | ||
reporter.Verbose(file.StaticWebAssetPath != null | ||
? $"> {file.FilePath}{Path.PathSeparator}{file.StaticWebAssetPath}" | ||
: $"> {file.FilePath}"); | ||
} | ||
} | ||
} | ||
|
||
public sealed class Loggers(IReporter reporter, string? binLogPath) : IEnumerable<ILogger>, IDisposable | ||
{ | ||
private readonly BinaryLogger? _binaryLogger = binLogPath != null | ||
? new() | ||
{ | ||
Verbosity = LoggerVerbosity.Diagnostic, | ||
Parameters = "LogFile=" + binLogPath, | ||
} | ||
: null; | ||
|
||
private readonly OutputLogger _outputLogger = | ||
new(reporter) | ||
{ | ||
Verbosity = LoggerVerbosity.Minimal | ||
}; | ||
|
||
public void Dispose() | ||
{ | ||
_outputLogger.Clear(); | ||
} | ||
|
||
public IEnumerator<ILogger> GetEnumerator() | ||
{ | ||
yield return _outputLogger; | ||
|
||
if (_binaryLogger != null) | ||
{ | ||
yield return _binaryLogger; | ||
} | ||
} | ||
|
||
public void ReportOutput() | ||
{ | ||
if (binLogPath != null) | ||
{ | ||
reporter.Verbose($"Binary log: '{binLogPath}'"); | ||
} | ||
|
||
_outputLogger.ReportOutput(); | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
=> GetEnumerator(); | ||
} | ||
|
||
private sealed class OutputLogger : ConsoleLogger | ||
{ | ||
private readonly IReporter _reporter; | ||
private readonly List<OutputLine> _messages = []; | ||
|
||
public OutputLogger(IReporter reporter) | ||
{ | ||
WriteHandler = Write; | ||
_reporter = reporter; | ||
} | ||
|
||
public IReadOnlyList<OutputLine> Messages | ||
=> _messages; | ||
|
||
public void Clear() | ||
=> _messages.Clear(); | ||
|
||
private void Write(string message) | ||
=> _messages.Add(new OutputLine(message.TrimEnd('\r', '\n'), IsError: false)); | ||
|
||
public void ReportOutput() | ||
{ | ||
_reporter.Output($"MSBuild output:"); | ||
BuildOutput.ReportBuildOutput(_reporter, Messages, success: false, projectDisplay: null); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.