Beispiel #1
0
        public Program(IConsole console, string workingDirectory)
        {
            // We can register the MSBuild that is bundled with the SDK to perform MSBuild things. dotnet-watch is in
            // a nested folder of the SDK's root, we'll back up to it.
            // AppContext.BaseDirectory = $sdkRoot\$sdkVersion\DotnetTools\dotnet-watch\$version\tools\net6.0\any\
            // MSBuild.dll is located at $sdkRoot\$sdkVersion\MSBuild.dll
            var sdkRootDirectory = Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "..");

#if DEBUG
            // In the usual case, use the SDK that contains the dotnet-watch. However during local testing, it's
            // much more common to run dotnet-watch from a different SDK. Use the ambient SDK in that case.
            MSBuildLocator.RegisterDefaults();
#else
            MSBuildLocator.RegisterMSBuildPath(sdkRootDirectory);
#endif

            Ensure.NotNull(console, nameof(console));
            Ensure.NotNullOrEmpty(workingDirectory, nameof(workingDirectory));

            _console          = console;
            _workingDirectory = workingDirectory;
            _cts = new CancellationTokenSource();
            console.CancelKeyPress += OnCancelKeyPress;
            _reporter = CreateReporter(verbose: true, quiet: false, console: _console);

            // Register listeners that load Roslyn-related assemblies from the `Rosyln/bincore` directory.
            RegisterAssemblyResolutionEvents(sdkRootDirectory);
        }
Beispiel #2
0
        public Program(IConsole console, string workingDirectory)
        {
            Ensure.NotNull(console, nameof(console));
            Ensure.NotNullOrEmpty(workingDirectory, nameof(workingDirectory));

            _console          = console;
            _workingDirectory = workingDirectory;
            _cts = new CancellationTokenSource();
            console.CancelKeyPress += OnCancelKeyPress;
            _reporter = CreateReporter(verbose: true, quiet: false, console: _console);
        }
Beispiel #3
0
 private static IReporter CreateReporter(bool verbose, bool quiet, IConsole console)
 => new PrefixConsoleReporter("watch : ", console, verbose || IsGlobalVerbose(), quiet);