Package restore failed VS 17 for MySql - asp.net-core

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

Related

There was an error running the selected code generator: 'Package restore failed. Rolling back package changes for 'OdeToFood''

Im trying add new controller , but i got this error. How can i solve this? enter image description here
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OdeToFood.Data\OdeToFood.Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.2">
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Pages\Api\" />
</ItemGroup>
</Project>
dotnet restore didn't work, clearing the componentcache didn't work

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.

Class library lost intellisense in VS2017 after .NET Core MVC auto-migration

After migrating a VS2015 MVC Core application with two projects (web app and class library) to VS2017 I've lost intellisense on all views within the class library. Pretty much everything in every single view is broken, so I'm sure it's something fairly basic that the migration tool didn't take care of for me. Even the #model directive in each razor view is an error.
The csproj looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AssemblyName>Library</AssemblyName>
<PackageId>Library</PackageId>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Views\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;#(EmbeddedResource)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="1.1.0" />
</ItemGroup>
</Project>
I tried duplicating the web.config from the web application to the root of the class library but that didn't help.
Looks like you've hit this bug:
https://github.com/aspnet/Mvc/issues/5975
Old Answer below
With the RTM version of VS 2017, you need to install the Razor Language Service extension to get back your Razor intellisense.
Unfortunately this component missed an internal ship date and as such did not make it as part of the actual VS 2017 release.
Uninstall the Razor Language Services by going to "Tools" > "Extensions and Updates".
Restart Visual Studio as per indication...
Reinstall Razor Language Services.
You will see razor intellisense working again such as asp-* tag helpers...
Two things were required to fix this issue, a change to the project SDK (<Project Sdk="Microsoft.NET.Sdk.Web">) and adding an element to set the output type to a library (<OutputType>Library</OutputType>). Full information on this GitHub issue I cross-posted.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<OutputType>Library</OutputType>
<AssemblyName>Library</AssemblyName>
<PackageId>Library</PackageId>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="Views\**" Exclude="bin\**;obj\**;**\*.xproj;packages\**;#(EmbeddedResource)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="1.1.0" />
</ItemGroup>
</Project>

No executable found matching command "dotnet-watch"

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