I installed .NET Core 2.1.105 on ubuntu from here
and created the sample web api project with dotnet new api-test
Then I tried to add the dotnet watcher package with
dotnet add package Microsoft.DotNet.Watcher.Tools
And when I issue a dotnet restore
I get the following error:
$ dotnet restore
Restoring packages for ~/devel/apps/dotnet/api_test/api_test.csproj...
Restore completed in 101.8 ms for ~/devel/apps/dotnet/api_test/api_test.csproj.
~/devel/apps/dotnet/api_test/api_test.csproj : error NU1605: Detected package downgrade: Microsoft.NETCore.App from 2.0.6 to 2.0.0. Reference the package directly from the project to select a different version.
~/devel/apps/dotnet/api_test/api_test.csproj : error NU1605: api_test -> Microsoft.DotNet.Watcher.Tools 2.0.1 -> Microsoft.NETCore.App (>= 2.0.6)
~/devel/apps/dotnet/api_test/api_test.csproj : error NU1605: api_test -> Microsoft.NETCore.App (>= 2.0.0)
Restore failed in 1.26 sec for ~/devel/apps/dotnet/api_test/api_test.csproj.
And this is my .csproj
file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.7" />
<PackageReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup>
</Project>
-- update
as stated in the answers bellow, dotnet watch should be included be part of he SDK from version 2.1, so I did this little test:
$ dotnet --version
2.1.105
$ dotnet new webapi -o tmp_api
The template "ASP.NET Core Web API" was created successfully.
$ cd tmp_api/
$ dotnet watch run
No executable found matching command "dotnet-watch"
--
dotnet watch is available from preview2 version onwards (which is available here)
Starting from .NET Core 2.1 Preview 2 the CLI tools like dotnet watch
are now part of the SDK:
We found that these tools were so popular that having to add them to individual projects didn’t seem like the right design, so we made them part of the SDK.
These tools were previously
DotNetCliToolReference
tools. They are no longer delivered that way. You can delete theDotNetCliToolReference
entries in your project file when you adopt .NET Core 2.1.