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>
Related
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
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
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>
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
I created an ASP.NET Core 1.1 xunit test project with the following csproj file:
<Project ToolsVersion="15.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk" Version="1.0.0-alpha-20161104-2">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0- preview-20161123-03" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLib\ClassLib.csproj"/>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
I am able to run the project using dotnet test using the command line but I don't see any information of how many tests passed or failed.
The version of the Dotnet Command line I am using is:
.NET Command Line Tools (1.0.0-preview4-004124)
How can I display the test results?
To make dotnet-test work, you also need to include a PackageReference to xunit.runner.visualstudio.
By the way, since you posted your question, the format for csproj has been greatly simplified. An xunit test project looks like this (as of Visual Studio 2017 RC, January and dotnet CLI 1.0.0-rc3-004350).
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="5.0.0-preview-20170125-04" />
<PackageReference Include="xunit" Version="2.2.0-beta5-build3474" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLib\ClassLib.csproj"/>
</ItemGroup>
</Project>