dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.44k stars 10.02k forks source link

dotnet watch does not watch custom file patterns from referenced projects #37191

Open david-jarman opened 3 years ago

david-jarman commented 3 years ago

dotnet version: 5.0.400

issue: I'm trying to use dotnet watch test to run unit tests whenever I modify a file in my csproj, including certain json files. I have two projects: Core.SDK.csproj and Core.SDK.Tests.csproj. The JSON files exist in Core.SDK.csproj, so I would like the unit test to run if those json files are modified. I run dotnet watch -p Core.SDK.Tests.csproj test and tests are run when .cs files are modified, but not the json files.

<!-- CoreSDK.csproj, in brief -->
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="Manifest/manifest-schema.json" CopyToOutputDirectory="Always" />
    <Content Include="Manifest/BuiltIn/*.json" CopyToOutputDirectory="Always" />
  </ItemGroup>

  <ItemGroup>
    <!-- extends watching group to include *manifest.json files -->
    <Watch Include="**/*.manifest.json" />
  </ItemGroup>
<!-- CoreSDK.Tests.csproj, in brief -->
  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\SDK.Core\SDK.Core.csproj" />
  </ItemGroup>

my investigation: I ran dotnet watch -p <proj> --list to see the exact files that dotnet watch is looking. For the CoreSDK project, everything looks as expected.

dotnet watch -p .\SDK.Core --list
...
.\platform\SDK.Core\bin\Debug\netstandard2.1\Manifest\BuiltIn\standard.manifest.json
.\platform\SDK.Core\Manifest\BuiltIn\standard.manifest.json
...

For the CoreSDK.Tests project, I see an issue, the files show as existing under the "SDK.Core.Tests" directory!

dotnet watch -p .\SDK.Core.Tests\ --list
...
.\platform\SDK.Core.Tests\bin\Debug\netstandard2.1\Manifest\BuiltIn\standard.manifest.json
.\platform\SDK.Core.Tests\Manifest\BuiltIn\standard.manifest.json
...

conclusion: Based on this output, dotnet watch thinks that standard.manifest.json should exist in directory of the test project. This path that it spit out does not exist, so it never sees a change in the file, and hence doesn't run tests when the actual json file from the CoreSDK project changes.

ghost commented 3 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.