Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

[dotnet-watch] Watching multiple projects #247

Closed
bromanko opened this issue Dec 21, 2016 · 6 comments
Closed

[dotnet-watch] Watching multiple projects #247

bromanko opened this issue Dec 21, 2016 · 6 comments

Comments

@bromanko
Copy link

Both dotnet build and dotnet test support glob patterns for multiple projects. For example, if I have a tests folder with two projects under it I am able to run dotnet test tests/** and it will execute the tests for both projects. It appears that watch only works when executing in a working directory with a project.json. Are there plans for glob pattern support or an ability to watch for changes across multiple projects?

@natemcmaster
Copy link
Contributor

natemcmaster commented Jan 3, 2017

No plans at the moment. As a prerequisite for this, we would need support for global or solution-level CLI tools (NuGet/Home#1605 and https://github.com/dotnet/cli/issues/4427).

However, the MSBuild version of dotnet-watch is much more extensible than the project.json version. You could implement yourself as an MSBuild file itself. Example: invoke dotnet watch msbuild /t:WatchAndTest on this project (dotnet-restore first to install)

<!-- watch.proj -->
<Project ToolsVersion="15.0">

    <Target Name="WatchAndTest">
        <ItemGroup>
            <TestProjects Include="test\**\*.csproj"/>
         </ItemGroup>
        <MSBuild Targets="VSTest" Projects="@(TestProjects)" />
    </Target>

  <ItemGroup>
    <Watch Include="**\*.cs" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild2-final" />
  </ItemGroup>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft.Common.targets"/>

</Project>

For triage consideration: add the example above to documentation?

@bromanko
Copy link
Author

bromanko commented Jan 4, 2017

That seems like it would work. Unfortunately, I am not quite ready to migrate these projects to using the msbuild version of tooling. That means I'm unable to test this at the moment. If you can confirm the process works I'd be happy to submit a PR adding it to the documentation.

@natemcmaster
Copy link
Contributor

It works, but I think we'll hold off on adding to documentation for now.

@muratg muratg added this to the Discussions milestone Mar 8, 2017
@muratg muratg changed the title Support for glob patterns [dotnet-watch] Watching multiple projects Mar 8, 2017
@muratg
Copy link

muratg commented Mar 8, 2017

@bromanko You should be able to move to csproj based tooling since it RTM'd yesterday.

@bromanko
Copy link
Author

bromanko commented Mar 8, 2017

That's my plan. I'll close this out.

@bromanko
Copy link
Author

I finally got around to implementing this. It worked great. One improvement I added was modifying the MSBuild task to stop on the first error:

<MSBuild Targets="VSTest" Projects="@(TestProjects)" StopOnFirstFailure="true" />

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants