- Bugfix: Trigger on new project.json file structure
- Bugfix: Trigger on folder deletion - Add test for folder deletion
This commit is contained in:
parent
526f22f072
commit
2cf772b575
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.DotNet.ProjectModel.Files;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Watcher.Core
|
||||||
|
{
|
||||||
|
internal static class IncludeContextExtensions
|
||||||
|
{
|
||||||
|
public static IEnumerable<string> ResolveFiles(this IncludeContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
return IncludeFilesResolver
|
||||||
|
.GetIncludeFiles(context, "/", diagnostics: null)
|
||||||
|
.Select(f => f.SourcePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.DotNet.ProjectModel.Files;
|
||||||
using Microsoft.DotNet.ProjectModel.Graph;
|
using Microsoft.DotNet.ProjectModel.Graph;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Watcher.Core.Internal
|
namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
|
|
@ -15,15 +17,34 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
ProjectFile = runtimeProject.ProjectFilePath;
|
ProjectFile = runtimeProject.ProjectFilePath;
|
||||||
ProjectDirectory = runtimeProject.ProjectDirectory;
|
ProjectDirectory = runtimeProject.ProjectDirectory;
|
||||||
|
|
||||||
Files = runtimeProject.Files.SourceFiles.Concat(
|
var compilerOptions = runtimeProject.GetCompilerOptions(targetFramework: null, configurationName: null);
|
||||||
runtimeProject.Files.ResourceFiles.Values.Concat(
|
|
||||||
runtimeProject.Files.PreprocessSourceFiles.Concat(
|
var filesToWatch = new List<string>() { runtimeProject.ProjectFilePath };
|
||||||
runtimeProject.Files.SharedFiles))).Concat(
|
if (compilerOptions?.CompileInclude != null)
|
||||||
new string[] { runtimeProject.ProjectFilePath })
|
{
|
||||||
.ToList();
|
filesToWatch.AddRange(compilerOptions.CompileInclude.ResolveFiles());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filesToWatch.AddRange(runtimeProject.Files.SourceFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compilerOptions?.EmbedInclude != null)
|
||||||
|
{
|
||||||
|
filesToWatch.AddRange(compilerOptions.EmbedInclude.ResolveFiles());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filesToWatch.AddRange(runtimeProject.Files.ResourceFiles.Values);
|
||||||
|
}
|
||||||
|
|
||||||
|
filesToWatch.AddRange(runtimeProject.Files.SharedFiles);
|
||||||
|
filesToWatch.AddRange(runtimeProject.Files.PreprocessSourceFiles);
|
||||||
|
|
||||||
|
Files = filesToWatch;
|
||||||
|
|
||||||
var projectLockJsonPath = Path.Combine(runtimeProject.ProjectDirectory, "project.lock.json");
|
var projectLockJsonPath = Path.Combine(runtimeProject.ProjectDirectory, "project.lock.json");
|
||||||
|
|
||||||
if (File.Exists(projectLockJsonPath))
|
if (File.Exists(projectLockJsonPath))
|
||||||
{
|
{
|
||||||
var lockFile = LockFileReader.Read(projectLockJsonPath, designTime: false);
|
var lockFile = LockFileReader.Read(projectLockJsonPath, designTime: false);
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,10 @@ namespace Microsoft.DotNet.Watcher.Core.Internal
|
||||||
foreach (var file in project.Files)
|
foreach (var file in project.Files)
|
||||||
{
|
{
|
||||||
closure.Add(file);
|
closure.Add(file);
|
||||||
|
|
||||||
|
// We need to add the folder because folder deletions only trigger
|
||||||
|
// for the folder, not for the files inside it
|
||||||
|
closure.Add(Path.GetDirectoryName(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var dependency in project.ProjectDependencies)
|
foreach (var dependency in project.ProjectDependencies)
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,24 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete an entire folder
|
||||||
|
[Fact]
|
||||||
|
public void DeleteSourceFolder()
|
||||||
|
{
|
||||||
|
using (var scenario = new GlobbingAppScenario())
|
||||||
|
using (var wait = new WaitForFileToChange(scenario.StartedFile))
|
||||||
|
{
|
||||||
|
scenario.Start();
|
||||||
|
|
||||||
|
var folderToDelete = Path.Combine(scenario.TestAppFolder, "include");
|
||||||
|
Directory.Delete(folderToDelete, recursive: true);
|
||||||
|
|
||||||
|
wait.Wait(_defaultTimeout,
|
||||||
|
expectedToChange: true,
|
||||||
|
errorMessage: $"Process did not restart because {scenario.StartedFile} was not changed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rename a file included in compilation
|
// Rename a file included in compilation
|
||||||
[Fact]
|
[Fact]
|
||||||
public void RenameCompiledFile()
|
public void RenameCompiledFile()
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"buildOptions": {
|
"buildOptions": {
|
||||||
"emitEntryPoint": true
|
"emitEntryPoint": true,
|
||||||
|
"compile": {
|
||||||
|
"include": [
|
||||||
|
"Program.cs",
|
||||||
|
"include/*.cs"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"exclude/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"compile": [
|
|
||||||
"Program.cs",
|
|
||||||
"include/*.cs"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"exclude/*"
|
|
||||||
],
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"netcoreapp1.0": {
|
"netcoreapp1.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue