Aspnetcore: dotnet-watch sur le projet ne détecte pas les nouveaux fichiers

Créé le 8 mars 2019  ·  3Commentaires  ·  Source: dotnet/aspnetcore

Décrivez le bogue

dotnet-watch sur un projet tel que décrit « Développer des applications ASP.NET Core à l'aide d'un observateur de fichiers » , et en particulier la section Exécuter des tests à l'aide de dotnet watch , ne détecte pas les ajouts de nouveau fichier.

Reproduire

Créez un répertoire pour le projet :

mkdir DotNetWatcherIssueDemo

Accédez au répertoire du projet :

cd DotNetWatcherIssueDemo

Initialisez-le avec un nouveau projet de test :

dotnet new nunit

Lancez VS Code sur le répertoire contenant le projet de test :

code .

Demandez à regarder le projet et à exécuter des tests sur les modifications :

dotnet watch test

À ce stade, vous devriez voir la sortie :

watch : Started
Build started, please wait...
Build completed.

Test run for A:\temp\DotNetWatchIssueDemo\bin\Debug\netcoreapp2.2\DotNetWatchIssueDemo.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 0.9364 Seconds
watch : Exited
watch : Waiting for a file to change before restarting dotnet...

Ajoutez maintenant un nouveau test à UnitTest1.cs :

diff --git a/UnitTest1.cs b/UnitTest1.cs
index 66ec70e..f6406e7 100644
--- a/UnitTest1.cs
+++ b/UnitTest1.cs
@@ -14,5 +14,11 @@ namespace Tests
         {
             Assert.Pass();
         }
+
+        [Test]
+        public void Test2()
+        {
+            Assert.Pass();
+        }
     }
 }
\ No newline at end of file

dotnet watch récupérera la modification, exécutera _deux_ tests avec succès et continuera à surveiller les modifications apportées au fichier :

watch : Started
Build started, please wait...
Build completed.

Test run for A:\temp\DotNetWatchIssueDemo\bin\Debug\netcoreapp2.2\DotNetWatchIssueDemo.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 0.9698 Seconds
watch : Exited
watch : Waiting for a file to change before restarting dotnet...

Dans un shell séparé, cd dans le répertoire du projet et ajoutez un nouveau fichier de test :

dotnet new nunit-test -n UnitTest2 -o .

Comportement attendu

À la dernière étape, je m'attendais dotnet watch ce que

Il semble qu'il crée une liste statique de fichiers et ne surveille que ceux-ci pour les modifications. Si je touche/enregistre de force le fichier de projet ( DotNetWatcherIssueDemo.csproj ) alors dotnet watch détecte le changement, reconstruit la liste de surveillance et détecte les modifications apportées au fichier ajouté, mais encore une fois, pas pour tout nouveau fichier ajouté par la suite.

Contexte supplémentaire

Sortie de dotnet --info :

.NET Core SDK (reflecting any global.json):
 Version:   2.2.101
 Commit:    236713b0b7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.101\

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  1.1.8 [C:\Program Files\dotnet\sdk]
  1.1.9 [C:\Program Files\dotnet\sdk]
  1.1.10 [C:\Program Files\dotnet\sdk]
  1.1.11 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

/cc @natemcmaster

affected-medium area-commandlinetools bug severity-minor

Commentaire le plus utile

D'après le commentaire suivant dans le code, il s'agit clairement d'un bogue et d'un manque :

https://github.com/aspnet/AspNetCore/blob/1f050242559e7b90ff6c4ee7f99d92b3a5af5a62/src/Tools/dotnet-watch/src/Internal/MsBuildFileSetFactory.cs#L66 -L67

Je dis un bogue parce que si c'est une limitation, alors ce n'est documenté nulle part.

Tous les 3 commentaires

D'après le commentaire suivant dans le code, il s'agit clairement d'un bogue et d'un manque :

https://github.com/aspnet/AspNetCore/blob/1f050242559e7b90ff6c4ee7f99d92b3a5af5a62/src/Tools/dotnet-watch/src/Internal/MsBuildFileSetFactory.cs#L66 -L67

Je dis un bogue parce que si c'est une limitation, alors ce n'est documenté nulle part.

Des progrès à ce sujet ?

+1 pour cela.

J'ai une configuration de flux de travail assez douce avec Verify , me permettant simplement d'itérer sur les tests, d'approuver les sorties et de relancer les tests. La seule partie qui manque, c'est quand je veux étendre ma suite de tests avec de nouveaux fichiers.

Une solution de contournement consiste à continuer à ajouter des classes de test dans le même fichier, puis à les séparer plus tard, mais c'est un peu pénible. Edit : Pas si mal avec la refactorisation rapide pour déplacer la classe vers un nouveau fichier lorsque vous les éliminez plus tard.

Cette page vous a été utile?
0 / 5 - 0 notes