Package Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86 - entity-framework-core

I want to update my packages but I got some errors like this:
The error is:
Error NU1202 Package Microsoft.EntityFrameworkCore.Sqlite
5.0.0-rc.1.20451.13 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package
Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 supports:
netstandard2.1 (.NETStandard,Version=v2.1) API
E:...\API\API.csproj 1
API.csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.8.20407.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-preview8" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
</ItemGroup>
</Project>
C:\WINDOWS\system32>dotnet --info .NET SDK (reflecting any
global.json):
Version: 5.0.100-rc.1.20452.10
Commit: 473d1b592e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program
Files\dotnet\sdk\5.0.100-rc.1.20452.10\
How can I solve this problem?

I had the same issue:
I updated my Visual Studio program from version 16.7 to 16.8 and now, problem solved!
I checked update manually
This solution is written in the comments of this question but I wanted to make it an answer to help others like me

You have to upgrade your nuget installer to latest version.
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite/
https://www.nuget.org/downloads
If you are using Azure Devops, you can add a task step into your pipeline.
- task: UseDotNet#2
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller#1
inputs:
versionSpec: ''
checkLatest: true

To develop any ASP.NET Core 5.0 app, you need Visual Studio 2019 version 16.8 or later, with the ASP.NET and web development workload installed.
https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net50
https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/create-project

I had a global.json file in my project. After removing it problem was fixed because it mentioned a .net core 3.1 sdk.

Open .csproj file in notepad and change the target version from 3.1 to 2.1
From
<TargetFramework>netstandard5.0</TargetFramework>
To
<TargetFramework>netstandard2.1</TargetFramework>
Save file and close. Clean Solution then rebuild the solution.

Related

Install .NET Standard version of a multi-target Nuget from a .NET 4.6.2 application?

Is it possible from a .NET 4.6.2 application to prefer .NET Standard version installation of a multi-target Nuget?
I have a .NET 4.6.2 application which is using a Nuget package built for both .NETFramework 4.6.2 and .NETStandard 2.0
When looking into the .csproj project file I can see this:
<Reference Include="CompanyAcme.TheNugetPackage.Client, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TheNugetPackage.Client.2.1.4\lib\net462\CompanyAcme.TheNugetPackage.Client.dll</HintPath>
</Reference>
Which makes me think that my .NET 4.6.2 application is using the .NET 4.6.2 version of the Nuget package.
You can do it with this filthy hack, but I'd certainly think twice before doing it
<PackageReference Include="Prism.Core" ExcludeAssets="Compile" GeneratePathProperty="true"> <Version>7.1.0.431</Version> </PackageReference>
<Reference Include="Prism"> <HintPath>$(PkgPrism_Core)lib\netstandard2.0\Prism.dll</HintPath> </Reference>
From https://duanenewman.net/blog/post/a-better-way-to-override-references-with-packagereference/

EF Core cannot install the Initial Migrations

These are the packages I have:
And this is my global.json file:
{
"sdk": {
"version": "3.1.101"
}
}
And this is my project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
</ItemGroup>
</Project>
Now I am trying to run this command but I get an error. What am I missing?
dotnet ef migrations add Initial
Error I get:
A compatible installed .NET Core SDK for global.json version [3.1.101] from [C:\MyRepoz\SportsSln\SportsStore\global.json] was not found
Install the [3.1.101] .NET Core SDK or update [C:\MyRepoz\SportsSln\SportsStore\global.json] with an installed .NET Core SDK:
1.1.14 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.508 [C:\Program Files\dotnet\sdk]
2.1.512 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
3.1.403 [C:\Program Files\dotnet\sdk]
OK the problem was that it specifically needs version 3.1.1 of .NET Core SDK.
So I went to their website and downloaded it and installed it.
Website is this: https://dotnet.microsoft.com/download/dotnet-core/3.1
Looks like dotnet is not recognised (you can verify it by typing dotnet --list-sdks, which should produce same error).
The solution should be to add env variable to PATH which points to the directory that contains SDKs. On Windows x64, this should be C:\Program Files\dotnet.
Also verify that C:\Program Files\dotnet\sdk\3.1.101 actually exists.

Microsoft.AspNetCore.App vs Microsoft.NETCore.App publishing problem

I have a .NET core 2.2 application which I'm trying to publish to my web hosting but I'm getting a "500 - Internal Server Error" as a result.
I contacted support and they located the problem as being the following:
We enabled detailed error for your website and it is showing "Handler >"aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list". It seems that you are using Microsoft.AspNetCore.App 2.2.1 for your website
application and this version is not installed on the server. Due to this website is not working.
On the server Microsoft.NETCore.App 2.2.1 is installed. So we would suggest you to re-deploy the application using .NetCore 2.2.1 and again check the website.
We only support .Net core runtimes installed on our shared hosting server. Re-deploy your application using the correct version to avoid any further issues. Please note that we do not support SCD (Self Contain Deployed application) on our shared server. We do support FDD (Framework Dependent Deployed application) only.
If I do a "dotnet --info" I can see that both .NETCore.App and AspNetCore.App are installed on my machine.
.NET Core SDKs installed:
2.2.103 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program > Files\dotnet\shared\Microsoft.NETCore.App]
My .csproj is referencing Microsoft.AspNetCore.App but it seems I cannot change this to Microsoft.NETCore.App.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1"/>
</ItemGroup>
</Project>
Is there any way I can deploy this app to use Microsoft.NETCore.App so it works on the server?

How do I ensure correct DotNet Core gets included in the build?

I am trying to deploy a .netcore 2.1.5 api to Windows 2012 Server R2
Currently my published api site gives the following error when I navigate to it
HTTP Error 502.5 - Process Failure
Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=808681
In the event log I can see
Event 1000, IIS AspNetCore Module
Application 'MACHINE/WEBROOT/APPHOST/MYSITE.COM.AU/MYAPINAME' with physical root 'C:\WebSites\MYSITE.COM.AU\MyApps\MYAPINAME\' failed to start process
commandline '.\dotnet .\mydllname.dll', ErrorCode='0x80004005 : 80008083
From this question
I see that I can include
<PublishWithAspNetCoreTargetManifest>False</PublishWithAspNetCoreTargetManifest>
In the publish profile If I want to ensure the correct version of DotNetCore gets installed on the host computer.
But how do I set that up if I want to use Azure Devops?
I tried checking Publish Web Projects in the Publish task
but I then get an error
No web project was found in the repository. Web projects are identified by
presence of either a web.config file or wwwroot folder in the directory.
Project file(s) matching the specified pattern were not found.
The dependencies include
Microsoft.AspNetCore.App 2.1.5
but I don't see a coresponding dll deployed.
I tried installing dotnet-runtime-2.1.5 on the computer, downloaded from
the installer site
[Update]
I noticed the logs folder was missing so I created it manually
[Update]
I added the task suggested by Eriawan
The YAML is
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
I get in the log
2018-10-29T08:29:05.4839748Z ##[section]Starting: Use .NET Core sdk 2.1.5
2018-10-29T08:29:05.4843909Z ==============================================================================
2018-10-29T08:29:05.4843981Z Task : .NET Core Tool Installer
2018-10-29T08:29:05.4844041Z Description : Acquires a specific version of .NET Core from internet or the tools cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks.
2018-10-29T08:29:05.4844089Z Version : 0.1.16
2018-10-29T08:29:05.4844134Z Author : Microsoft Corporation
2018-10-29T08:29:05.4844192Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=853651)
2018-10-29T08:29:05.4844234Z ==============================================================================
2018-10-29T08:29:05.9812262Z Tool to install: .NET Core sdk version 2.1.5.
2018-10-29T08:29:05.9825645Z Checking if a cached copy exists for this version...
2018-10-29T08:29:05.9830151Z Cache does not contains this particular .NET Core. Will be downloaded and installed.
2018-10-29T08:29:05.9833458Z Detected platform (Primary): win-x64
2018-10-29T08:29:05.9833723Z Getting URL to download .NET Core sdk version: 2.1.5.
2018-10-29T08:29:06.5248134Z Could not fetch download information for version 2.1.5. Please check if the version specified is correct. You can refer the link for supported versions => https://github.com/dotnet/core/blob/master/release-notes/releases.json. Falling back to creating convention based URL.
2018-10-29T08:29:06.5481883Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\DotNetCoreInstaller_b0ce7256-7898-45d3-9cb5-176b752bfea6\0.1.16\externals\install-dotnet.ps1' -Version 2.1.5 -DryRun"
2018-10-29T08:29:07.6386710Z dotnet-install: Payload URLs:
2018-10-29T08:29:07.6387117Z dotnet-install: Primary - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T08:29:07.6387245Z dotnet-install: Legacy - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T08:29:07.6387445Z dotnet-install: Repeatable invocation: .\install-dotnet.ps1 -Version 2.1.5 -Channel LTS -Architecture x64 -InstallDir <auto>
2018-10-29T08:29:07.6451802Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T08:29:08.8792388Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip Error: {}
2018-10-29T08:29:08.8807163Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T08:29:09.5450400Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip Error: {}
2018-10-29T08:29:09.5453128Z ##[error]Failed to download package for installation
2018-10-29T08:29:09.5551776Z ##[section]Finishing: Use .NET Core sdk 2.1.5
The designer shows
The csproj is
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp2.1\trackApi.xml</DocumentationFile>
<DefineConstants>TRACE;DEBUG;NETCOREAPP2_1</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp2.1\trackApi.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Folder Include="logs\" />
<Folder Include="Views\Account\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
[Update]
problems in build pipeline
[Update]
I created a new pipeline using YAML
pool:
vmImage: 'VS2017-Win2016'
variables:
buildConfiguration: 'Debug'
steps:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
- task: DotNetCoreCLI#2
displayName: Restore
inputs:
command: restore
projects: '**/Api*.csproj'
However I still get an error
018-10-29T09:36:13.7155347Z ##[section]Starting: Use .NET Core sdk 2.1.5
2018-10-29T09:36:13.7158688Z ==============================================================================
2018-10-29T09:36:13.7158742Z Task : .NET Core Tool Installer
2018-10-29T09:36:13.7158774Z Description : Acquires a specific version of .NET Core from internet or the tools cache and adds it to the PATH. Use this task to change the version of .NET Core used in subsequent tasks.
2018-10-29T09:36:13.7158842Z Version : 0.1.16
2018-10-29T09:36:13.7158878Z Author : Microsoft Corporation
2018-10-29T09:36:13.7158926Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=853651)
2018-10-29T09:36:13.7158958Z ==============================================================================
2018-10-29T09:36:14.1220877Z Tool to install: .NET Core sdk version 2.1.5.
2018-10-29T09:36:14.1231419Z Checking if a cached copy exists for this version...
2018-10-29T09:36:14.1238258Z Cache does not contains this particular .NET Core. Will be downloaded and installed.
2018-10-29T09:36:14.1240864Z Detected platform (Primary): win-x64
2018-10-29T09:36:14.1240993Z Getting URL to download .NET Core sdk version: 2.1.5.
2018-10-29T09:36:14.5706519Z Could not fetch download information for version 2.1.5. Please check if the version specified is correct. You can refer the link for supported versions => https://github.com/dotnet/core/blob/master/release-notes/releases.json. Falling back to creating convention based URL.
2018-10-29T09:36:14.5957734Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& 'D:\a\_tasks\DotNetCoreInstaller_b0ce7256-7898-45d3-9cb5-176b752bfea6\0.1.16\externals\install-dotnet.ps1' -Version 2.1.5 -DryRun"
2018-10-29T09:36:15.3109409Z dotnet-install: Payload URLs:
2018-10-29T09:36:15.3109790Z dotnet-install: Primary - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T09:36:15.3109942Z dotnet-install: Legacy - https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T09:36:15.3110089Z dotnet-install: Repeatable invocation: .\install-dotnet.ps1 -Version 2.1.5 -Channel LTS -Architecture x64 -InstallDir <auto>
2018-10-29T09:36:15.3188675Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip
2018-10-29T09:36:16.5236693Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-sdk-2.1.5-win-x64.zip Error: {}
2018-10-29T09:36:16.5256084Z Downloading: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip
2018-10-29T09:36:17.2185860Z ##[warning]Could not download installation package from this URL: https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip Error: {}
2018-10-29T09:36:17.2189408Z ##[error]Failed to download package for installation
2018-10-29T09:36:17.2271136Z ##[section]Finishing: Use .NET Core sdk 2.1.5
The url https://dotnetcli.azureedge.net/dotnet/Sdk/2.1.5/dotnet-dev-win-x64.2.1.5.zip shows an error
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>BlobNotFound</Code>
<Message>
The specified blob does not exist. RequestId:7447502f-301e-00a8-516d-6f7cde000000 Time:2018-10-29T09:57:58.4200303Z
</Message>
</Error>
[Update]
Eriawan has the answer.
I needed to use a YAML pipeline and get the version here.
In order to control the build to use specific version of .NET Core runtime, you must tell the build agent to install the .NET Core SDK to use and also specify the SDK version to install before building your code.
If you use YAML on your Azure DevOps Pipelines build, you could run this task: DotNetCoreInstaller#0 and set the version of to 2.1.403 .
The task must be run before any tasks, preferably the first task to run.
For example:
- task: DotNetCoreInstaller#0
inputs:
version: '2.1.403'
If you're using the build definition designer, add the ".NET Core Tool Installer" task and specify the version that you want to use from there.
Please consult .NET Core build sample on MSFT docs:
https://learn.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core?view=vsts&tabs=yaml#build-environment
UPDATE 1:
OK, I have seen your build error. Looks like the .NET Core installer task has wrong URL address for .NET Core SDK of 2.1.403.
You can use pure YAML instead. I will file a bug on the .NET Core installer task repo. In the meantime, please use a full YAML.
I already have one working YAML file, a sample of this is available on my own repo.
For example:
https://github.com/RXCommunica/rx-azuredevops-rest/blob/master/azuredevopsrest-ci-vs2017.yml
UPDATE 2:
I have added comments for your YAML. The .NET Core tool version on your YAML is incorrect. Update/change your yaml from the original:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.5
to:
- task: DotNetCoreInstaller#0
displayName: 'Use .NET Core sdk 2.1.5'
inputs:
version: 2.1.403
This is important, because version of .NET Core runtime is not equal to the version of the actual SDK tool version.
Please consult this doc for the tool version and the related runtime list of .NET Core 2.1:
https://www.microsoft.com/net/download/dotnet-core/2.1

dotnet restore with update in the new csproj/msbuild-based projects?

How do I actually update the new csproj-based project's Nuget packages to the latest ones when using Visual Studio Code?
This is what I have within the .csproj file:
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.0" />
If I do dotnet restore it will only install the specified package versions.
There is no dotnet restore update or dotnet nuget update option available.
All of the above referenced Microsoft.AspNetCore.* packages have newer versions (1.1.0).
I would like to update the packages and have the references updated automatically in the same way we do this in Visual Studio.
Currently, VS Code does not have a built-in Nuget Manager tool. The only possible way is to edit .csproj file manually and update versions.
If regarding VS Code extensions, there is a Net Core Project Manager extension, that works pretty well.