Coder Guy
Coder Guy

Reputation: 325

dotNet watcher, watch only .dll file

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

Upvotes: 3

Views: 985

Answers (1)

tkit
tkit

Reputation: 8642

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.

Upvotes: 1

Related Questions