private async Task <IFileSet> GetFileSet(MsBuildFileSetFactory filesetFactory)
 {
     _tempDir.Create();
     return(await filesetFactory
            .CreateAsync(CancellationToken.None)
            .TimeoutAfter(TimeSpan.FromSeconds(30)));
 }
Beispiel #2
0
        private async Task <IFileSet> GetFileSet(MsBuildFileSetFactory filesetFactory)
        {
            _tempDir.Create();
            var createTask = filesetFactory.CreateAsync(CancellationToken.None);
            var finished   = await Task.WhenAny(createTask, Task.Delay(TimeSpan.FromSeconds(10)));

            Assert.Same(createTask, finished);
            Assert.NotNull(createTask.Result);
            return(createTask.Result);
        }
Beispiel #3
0
        private async Task <int> ListFilesAsync(
            IReporter reporter,
            string project,
            CancellationToken cancellationToken)
        {
            // TODO multiple projects should be easy enough to add here
            string projectFile;

            try
            {
                projectFile = MsBuildProjectFinder.FindMsBuildProject(_workingDirectory, project);
            }
            catch (FileNotFoundException ex)
            {
                reporter.Error(ex.Message);
                return(1);
            }

            var fileSetFactory = new MsBuildFileSetFactory(reporter,
                                                           DotNetWatchOptions.Default,
                                                           projectFile,
                                                           waitOnError: false,
                                                           trace: false);
            var files = await fileSetFactory.CreateAsync(cancellationToken);

            if (files == null)
            {
                return(1);
            }

            foreach (var group in files.GroupBy(g => g.FileKind).OrderBy(g => g.Key))
            {
                if (group.Key == FileKind.StaticFile)
                {
                    _console.Out.WriteLine("::: Watch Action: Refresh browser :::");
                }

                foreach (var file in group)
                {
                    if (file.FileKind == FileKind.StaticFile)
                    {
                        _console.Out.WriteLine($"{file.FilePath} ~/{file.StaticWebAssetPath}");
                    }
                    else
                    {
                        _console.Out.WriteLine(file.FilePath);
                    }
                }
            }

            return(0);
        }
Beispiel #4
0
        private async Task <int> ListFilesAsync(
            IReporter reporter,
            string project,
            CancellationToken cancellationToken)
        {
            // TODO multiple projects should be easy enough to add here
            string projectFile;

            try
            {
                projectFile = MsBuildProjectFinder.FindMsBuildProject(_workingDirectory, project);
            }
            catch (FileNotFoundException ex)
            {
                reporter.Error(ex.Message);
                return(1);
            }

            var fileSetFactory = new MsBuildFileSetFactory(
                reporter,
                DotNetWatchOptions.Default,
                projectFile,
                waitOnError: false,
                trace: false);
            var files = await fileSetFactory.CreateAsync(cancellationToken);

            if (files == null)
            {
                return(1);
            }

            foreach (var file in files)
            {
                _console.Out.WriteLine(file.FilePath);
            }

            return(0);
        }