3

I use the command dotnet watch run while developing dotnet core applications. However, I want the watcher only to watch if the .dll file in the bin folder has changed, and only then should it rebuild the application. In other words, I want the dotnet console app to re-run when I build my project/solution.

I tried to override the default behaviour of the watcher in the .csproj to accomplish this, as stated here.

<ItemGroup>
   <Watch Include = "**/*.dll">

   <Watch Exclude = "**/*.cs">
   <Watch Exclude = "**/*.resx">
   <Watch Exclude = "*.csprj">
</ItemGroup

but it doesn't work. Could anyone help me with this?

Thanks

Coder Guy
  • 185
  • 5
  • 12

1 Answers1

1

You missed the last >. Maybe that was just a typo when you were copying over code to SO.

You could try putting it all in one line like this:

<ItemGroup>
   <Watch Include="**/*.dll" Exclude="**/*.cs;**/*.resx;**.*.csproj">
</ItemGroup>

I just tested this on a solution of mine which has 11 projects, and it worked. I had to add it to every csproj file though (and yes, I have .csproj files, not .csprj, not sure .csprj is even a thing, perhaps another typo).

Reference - docs.

tkit
  • 8,082
  • 6
  • 40
  • 71
  • Thank you for your answer . I never managed to fix the issue and just left it. I will try your solution though – Coder Guy Aug 23 '20 at 23:12
  • I thought so :D But I guess since I found the question, and found the answer somewhere else.. if someone else finds your question, it might help! Cheers – tkit Aug 23 '20 at 23:17