No executable found matching command "dotnet-watch" - asp.net-core

Trying to use dotnet watch but gettin an error:
No executable found matching command "dotnet-watch"
dotnet --version
1.0.0-rc4-0004834
Installed .NET Core 1.1 SDK and .NET Core 1.1 runtime
My .csproj file:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="1.0.0-rc4-004771" />
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
<PackageReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.1.0-preview4-final" />
</ItemGroup>
dotnet restore has done
How can I solve that?

Add Microsoft.DotNet.Watcher.Tools to your .csproj as below :
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild2-final" />
</ItemGroup>
then excute dotnet restore and dotnet watch run

Related

Why do I need to install the EntityFrameworkCore nuget package when moving my project to a new machine?

Maybe I didn't install the package correctly to begin with, please let me know, but after I moved my project to a new machine, installed .Net Core SDK 3.1 (latest) and cloned my project from Github, I had to go and install this nuget package manually:
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore
When I first opened up the project in VS Code I had like 200+ errors for missing files.
I installed the EntityFrameworkCore package in my project folder and that fixed it.
QUESTION - I didn't have to install any of the other packages below (ex. SendGrid), so why this one?
Did I not install it correctly initially on my other computer? So maybe it didn't check in the reference or something? But the reference is in the .csproj file below!
Here are all the other packages I'm using and none had to be manually installed except
Microsoft.EntityFrameworkCore 3.1.3
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="3.1.3" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
<!-- <PackageReference Include="NetTopologySuite" Version="2.0.0" /> -->
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="CloudinaryDotNet" Version="1.8.0" />
<PackageReference Include="SendGrid" Version="9.12.0" />

Upgrade .net core 2.2.0 to 2.2.6 or above

Looking for steps to upgrade .Net core 2.2.0 to 2.2.6 or higher (not 3.0)
I am new to .net core. So looking for guidance on how to upgrade .net core 2.2 to 2.2.6 as app is failing while pushing to Pivotal cloud foundry. Our PCF environment dotnetcore buildpack version is 2.2.12; Used to work before using 2.2.5 build pack. Please find error message below. To resolve this error , though of upgrading .net core app to versions higher than 2.2.5. But would like to seek help on steps to follow for upgrading the app & respective dependencies.
Here is targetframework from .csproj
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
And dependencies are
<ItemGroup>
<PackageReference Include="AutoMapper" Version="8.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.1.0" />
<PackageReference Include="CsvHelper" Version="12.1.2" />
<PackageReference Include="EFCore.BulkExtensions" Version="2.4.6" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.3.0" />
<PackageReference Include="Manulife.Logging.DotNet" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.2.4" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
<PackageReference Include="Sendgrid" Version="9.11.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Steeltoe.CloudFoundry.Connector.EFCore" Version="2.2.0" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="2.2.0" />
<PackageReference Include="Steeltoe.Extensions.Logging.DynamicLogger" Version="2.2.0" />
<PackageReference Include="Steeltoe.Security.Authentication.CloudFoundryCore" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
Error while pushing app to Pivotal (during dotnet publish)
depends on runtime.linux-x64.Microsoft.NETCore.App (>= 2.2.5) but run
time is not found. Picked up 2.2.6 which is available
/tmp/app/Basischangeapp/Basischange.csproj : error NU1605: Detected
package downgrade: Microsoft.NETCore.DotNetAppHost from 2.2.6 to 2.2.5.
Reference the package directly from the project to select a different
version.
It will happen because of version mismatch between local SDK and the build server.
Add this line to your .csproj file:
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
After that, RuntimeFrameworkVersion will use LatestNetCorePatchVersion.

Package restore failed VS 17 for MySql

I just installed Visual studio 2017 and I wish to create a Web API. I want to use MySql as my database.
My .csproj looks like following:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
For MySql I went into NuGet package manager and searchedfor mysql.data which shows me the latest stable version to be 6.9.9. When I try to install it, I get Package restore failed error.
Am I doing something wrong?
UPDATE: I was also referring to http://insidemysql.com/getting-started-with-asp-net-core-and-mysql-connectornet/ this tutorial
I decided to go with Pomelo.EntityFrameworkCore.MySql

ASP.NET Core Web API and OpenIddict

I'm trying to use OpenIddict to my asp.net core web api project. I have followed the instructions written here but when i try to build the project i get the following error
Unable to resolve 'OpenIddict.Mvc (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'.
I have created the project through Visual Studio 2017 (I suppose i have the latest .NET Core tooling installed by default). Any ideas?
UPDATE:
The 1st step of the instructions says that you have to update your packages to reference the ASP.NET Core RTM packages. What that means?
And my .csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="$(AspNetContribOpenIdExtensionsVersion)" />
<PackageReference Include="OpenIddict" Version="$(OpenIddictVersion)" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="$(OpenIddictVersion)" />
<PackageReference Include="OpenIddict.Mvc" Version="$(OpenIddictVersion)" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\iBoard.Repositories\iBoard.Repositories.csproj" />
</ItemGroup>
</Project>
I have also tried with Version="1.0.0-*"
Add the missing OpenIddictVersion/AspNetContribOpenIdExtensionsVersion properties in your .csproj and it should work:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AspNetContribOpenIdExtensionsVersion>1.0.0-*</AspNetContribOpenIdExtensionsVersion>
<OpenIddictVersion>1.0.0-*</OpenIddictVersion>
</PropertyGroup>
</Project>
Alternatively, you can also directly hardcode the right version:
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0-*" />
<PackageReference Include="OpenIddict" Version="1.0.0-*" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-*" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-*" />
</ItemGroup>
</Project>

Wrong App.Config publish.targets MSBuild 15

I posted this question on GitHub/Microsoft/MSBuild but I'm hoping the wider community might have some early experience with this.
I'm working on converting a solution / projects from VS 2015 (.NET core preview) to VS 2017 and latest .NET Core.
The solution now builds perfectly fine in Visual Studio 2017 but the issue I encounter is when trying to run a build using MSBuild 15 (I can't use v14 because of the .NET Core projects). It fails on trying to copy the .config file from the obj\debug\net452 folder but for some reason it's adding the full .csproj name
The issue is that the Publish.Targets are doing something weird with the .config file.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets(128,5):
error MSB3030: Could not copy the file "obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config" because it was not found.
[C:\Projects\Sitecore.Demo.Retail\src\Foundation\Commerce\Engine\code\Sitecore.Foundation.Commerce.Engine.csproj]
It's prepending the full project name (including .csproj) to the name of the config file rather than just using the AssemblyName.
In this case, Sitecore.Foundation.Commerce.Engine.csproj is the project and code is the AssemblyName (it will eventually be renamed to something better). As you can see it's looking for "Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config" which doesn't exist. code.exe.config does exist though.
I'm happy to give GitHub repo access to anyone interested in helping figure this one out with me as it's blocking us from making the repository public.
so code.exe.config is resolved as Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config
OUTPUT snippet from MSBuild:
08:13:09.957 1>Target "GenerateBindingRedirectsUpdateAppConfig: (TargetId:127)" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Projects\Sitecore.Demo.Retail\src\Foundation\Commerce\Engine\code\Sitecore.Foundation.Commerce.Engine.csproj" (target "ResolveReferences" depends on it):
Set Property: AppConfig=obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config
Added Item(s):
AppConfigWithTargetPath=
obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config
TargetPath=code.exe.config
Here is the Sitecore.Foundation.Commerce.Engine.csproj content:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<PreserveCompilationContext>false</PreserveCompilationContext>
<AssemblyName>code</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>code</PackageId>
</PropertyGroup>
<!--<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>-->
<ItemGroup>
<ProjectReference Include="..\..\legacyCommerce\Plugin.Sample.Habitat\Plugin.Sample.Habitat.csproj" />
<ProjectReference Include="..\..\legacyCommerce\Plugin.Sample.Payments.Braintree\Plugin.Sample.Payments.Braintree.csproj" />
<ProjectReference Include="..\..\legacyCommerce\Sitecore.Commerce.Plugin.AdventureWorks\Sitecore.Commerce.Plugin.AdventureWorks.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="6.0.0-alpha1-rtm-121216" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.1.0" />
<PackageReference Include="Serilog" Version="2.4.0" />
<PackageReference Include="Sitecore.Commerce.Core" Version="1.0.2301" />
<PackageReference Include="Serilog.Sinks.Literate" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="1.0.2" />
<PackageReference Include="Sitecore.Commerce.Provider.FileSystem" Version="1.0.2301" />
<PackageReference Include="Sitecore.Framework.Rules" Version="1.1.12" />
<PackageReference Include="Sitecore.Framework.Rules.Serialization" Version="1.1.12" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Sitecore.Framework.Diagnostics" Version="1.1.4" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
It turns out one of our NuGet references had a dependency on an incompatible package. This in turn manifested itself in a very weird way.
I'm sorry if this doesn't help anyone else but this seems to have resolved our specific issue.