Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package - asp.net-core

I am trying to deploy stateless micro service application into service fabric but I get this error as soon as I start the deployment.
Project is targeting runtime 'win7-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core.
How to fix this ?

If you're unable to upgrade to .NET Core 3.1, you can suppress this error by adding this inside a <PropertyGroup> in your project file:
<EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime>
The error is a design-time error and won't cause a runtime failure.

If you create your stateless micro service application on VS2019, you should note that Net Core <=3.0 is not supported by Stateless project.
So you should target your project framework to at least Net Core 3.1.
Right-click on your project Properties-->Application-->change target framework version to net core 3.1.
If I target project into net core 2.2, the error will happen.
Note that, you should make sure that your target framework version of the pubxml file is the same of your project target framework version.

Related

Why does netcore3.1 framework cause this error?

I have an aspnetcore api project I wrote in .net core 2.2, and changed the targeted framework in the csproj file to .net core 3.1. The project now has the following error (NETSDK1):
The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web.
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets
The Nuget Viewer for the project has no such project listed, and the error is occurring in a file outside my project. Does anyone know how to fix this?

.Net Core Project Referencing .Net Frameork Projects Problems?

I have a question about .net Core project.
I have a .Net Core Project referencing other projects.
The problem is that a few projects show the warning saying that "Package 'XXXXX' was restored using .NetFramework, Version=v4.6.1.... instead of targer framework .NetCoreApp".
What kind of problems could I have?
Also can I deploy this in Linux for instance and still working fine?
warning showed
Thanks guys
Look at this thread - For a .Net Core 2.1 project, Why does Nuget restores .Net 4.6.1 packages?
What it basically means is the package you have loaded not suitable for .NET CORE, and was restored using a different version of .Net Framework.
Check if the package exists for .NET CORE (search thru NuGet Manager)
Regarding whether it will work on Linux or not - it depends on the package dependencies (e.g. if it is depending on WinForm for example, it probably won't work on Linux).
Even if it will work, I suggest finding a package suitable for .NET CORE.

Error in Visual Studio CI/CD .Net Core Project

We faced lots of build errors on Visual Studio CI/CD for .net core project but this is our last error and we can't figure it out.
Our project is based on .net core v1.1 and the last error asked us to upgrade to .net core v2.0 and we did that.
All of the CI steps are succeed expect dotnet ef migrations:
This is error message:
Method 'get_Properties' does not have an implementation. in type
'Microsoft.Extensions.Configuration.ConfigurationBuilder' from
assembly 'Microsoft.Extensions.Configuration, Version=1.1.2.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Note: The project is building local machine and on Visual Studio CI
It looks like you did not upgrade your solution successfully to .net core 2.x., since you're configuration is still depending on on a package from 1.1.
You should upgrade Microsoft.Extensions.Configuration to 2.0 (2.1.1, if you're on .net core 2.1)
Update-Package Microsoft.Extensions.Configuration -version 2.0.0 -reinstall
https://www.nuget.org/packages/Microsoft.Extensions.Configuration/

ASP.NET Core self-contained exe

I want my ASP.NET Core Web API to run as a self-contained exe within the .NET framework and not .NET Core Framework. Is that possible? Thanks!
EDIT:
If I add "net451": {} to my frameworks section in project.json,
I get the following exception:
Failed to make the following project runnable: myProject (.NETCoreApp,Version=v1.0) reason: Expected coreclr library not found in package graph. Please try running dotnet restore again.
You can't create a self-contained app which targets .NET Framework >=4.5, because the full .NET Framework isn't modular and its not possible to have more than one version of it installed. Newer versions basically always replace the previous one.
Self-contained apps were one main motivation for .NET Core (together with portability)
You ALWAYS have to install .NET >=4.5 before your app can run. self-contained apps only work with .NET Core because .NET core libraries can be pulled through nuget package.
For .NET 4.6 you can only create portable apps, which is the default mode.

Bamboo Build .Net Framework 2.0

My project failed to build on Bamboo server, but my project successfully built on my local machine. My project is using the .Net Framework 2.0.
Error:
LC : error LC0000: 'Could not load file or assembly 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Internals\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Internals.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.' [C:\Atlassian\Bamboo-Home\xml-data\build-dir\23822338\OCODEA-MER-JOB1\BACKOFFICE\example.csproj]
You're trying to build .net 2 with msbuild from .net 4. Are you sure there is .net 2 on the bamboo agent? and it would probably help if you build it with msbuild 2.0. That whay you know for sure the frameworks there. For sinplicity.