How to build application targetting .Net 4/4.5 on CentOs - msbuild

I have a lot of legacy code that builds fine on Windows with .Net 4.5
I am trying to build the same on CentOS with dotnet-sdk for automation and licensing issues.
Following the Microsoft link after installing the required packages, this command fails
$ dotnet msbuild sharpTest.sln
/usr/share/dotnet/sdk/5.0.301/Microsoft.Common.CurrentVersion.targets(1216,5): error MSB3644: The reference
assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack
(SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework
Developer Packs at https://aka.ms/msbuild/developerpacks
Since I installed dotnet-sdk-5, it seems the solution fails to build. But I could not locate .Net framework 4 for CentOS
How do I resolve this ?

It's referencing .NETFramework. .NETFramework V4.0 is not xplat and therefore not available on anything else than windows. You should try to re-target your solution to net5.0 and make it independent of Windows specific dependencies.
To re-target to net5.0 try the dotnet upgrade-assistant (it's a dotnet tool). Do this on a windows machine first. To address any windows dependencies that won't work outside windows or .NetFramework see the Overview of porting from .NET Framework to .NET

Related

Correct .NET Core SDK to build netstandard20 library

I have a few libraries with target framework netstandard20. These libraries are consumed by a few .net framework 4.6.1 libraries.
The IT department uninstalled the .NET Core 2.0 from the build server because of some security vulnerability. All the libraries that use netstandard20 are now failing with the following error:
C:\bamboo6104...>nuget restore
MSBuild auto-detection: using msbuild version '16.11.2.50704' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin'.
C:\bamboo6104\xml-data\build-dir\BAM-CUS-JOB1...\netstandard\xxx.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
The Build Server already has Visual Studio 2019. What version of SDK need to be installed for the build to pass? I have the following SDKs on my laptop:
Will installing 2.1.526 version resolve the build issue?
I can't upgrade the libraries to .NET 5 or 6 due to we have numerous libraries with the same problem and upgrade is not a priority.

dotnet command not working on centos server, runtime installed

I installed aspnet core runtime (aspnetcore-runtime-3.1.3) on a centOS 7 server.
following this guide from microsoft documentation: https://learn.microsoft.com/en-us/dotnet/core/install/runtime?pivots=os-linux#download-and-manually-install
my server doesn't have internet connection.
After installation, when I run any command, e.g.
dotnet --info
it says it can't find any installed dotnet sdk:
$ dotnet --info
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download
Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8
.NET Core SDKs installed:
No SDKs were found.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.3 [/home/myuser/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.3 [/home/myuser/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Previously, I downloaded the rpm package and installed it with rpm -ivh command, same result
What can I do to fix this?
Note that I don't have internet access in the server
EDIT: The problem: I don't need SDK to run this command or any command I am using.
Anyways I've tried installing SDK, it says it can't find any compatible frameworks
What is the problem? you just installed runtime, and the error says there is no sdk.
You installed the .net runtime but didn't install the any sdk. for you to be able use asp.net core you need to install both. you can visit asp.net core documentation for the difference between them. but you can just visit https://dotnet.microsoft.com/download to download the appropriate sdk you need.
nb: I assume you are doing this from a gui. i'm sure there are commands for installing the asp.net core runtime and SDK from command prompt. but what is important is that YOU ARE MISSING THE SDK!!

.NET Blazor Build error

I have tried to run the out of the box Blazor application to try out C# WebAssembly. I am running into issues when trying to run it different ways. I have also tried to hack the runtimeconfig.json according to this https://github.com/dotnet/cli/issues/7543
Running IIS Express
Running BlazorApplication1
The program '[42032] dotnet.exe' has exited with code -2147450749 (0x80008083).
Running in command line
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview3-25512-01' was not found.
- Check application dependencies and target a framework version installed at:
\
- Alternatively, install the framework version '2.0.0-preview3-25512-01'.
You need to have the 2.1 preview of the .net core framework installed for Blazor to work: download here

TeamCity can't build a portable/custom targeted library

I have a solution with a core library that is portable, targeted at Windows Store, .NET 4.5 and Windows Phone 8.0
This project will not build via TeamCity.
[12:31:36][GetReferenceAssemblyPaths] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(983, 5): warning MSB3644: The reference assemblies for framework ".NETPortable,Version=v4.5,Profile=Profile78" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Is this a known problem or do I have to install something?
Install the Windows Phone SDK. Although the portable library offer's a bunch of platforms to be commonly compatible with, it still needs the relevant SDKs installed.

Why it always report .net core SDK not installed while it already here?

I am going to debug my asp.net core project in the windows server 2012R2 while the VSCode reports this.
Then I installed the .net core SDK.
However, the error above comes again.
Well, in the Programs and Features of Control Panel, it is installed already yet.
It is so strange that in the Powershell of dotnet --info.
It said that no SDKs were found.
Why it turns out to be this?
And how can I install the .net core SDK correctly?
PS: the computer is an X64 system.
I noticed that I have installed both X86/X64 Runtimes.
After I uninstalled the X86 Runtime, it works.