ASP.NET Core 1.1 Development on RedHat Enterprise Linux 7.3 - asp.net-core

I'm have an an ASP.NET Core application that was created using Visual Studio 2017 on Windows 10. It works as expected running the following commands
cd src
dotnet restore
dotnet build
cd Hello.Portal
dotnet run
See build.cmd in the repository for more details.
My next objective is to create a build.sh for RHEL 7, which would end up with an RPM (but that is outside the scope of this question). To prepare for that I did the following:
Create an RHEL 7.3 virtual machine in VMware Workstation
Followed the instructions to install dotnet core 1.1 in the VM.
I then ran the following commands on Windows 10 to create a self-contained deployment.
dotnet restore --runtime rhel.7-x64
dotnet publish --framework netcoreapp1.1 --runtime rhel.7-x64
I then SFTP the output over to the VM and the application works as expected.
I then cloned the GIT repository to the RHEL VM and then ran the following commands, assuming that it would work the same way it did for Windows.
cd src
dotnet restore
dotnet build
However it failed with the following errors:
[werners#localhost src]$ dotnet restore
warn : The folder '/home/werners/development/hello/src' does not contain a project to restore.
[werners#localhost src]$ dotnet build
Couldn't find 'project.json' in current directory
[werners#localhost src]$
This looks rather suspicious. So I logged out and logged back in and the ran the following commands:
[werners#localhost ~]$ scl enable rh-dotnetcore11 bash
[werners#localhost ~]$ dotnet --version
1.0.0-preview2-1-003176
On Windows, the version returns the following:
S:\hello\src>dotnet --version
1.0.3
So it looks like rh-dotnetcore11 doesn't have the latest released version of .NET core command line.
To validate, I ran the following as root.
[root#localhost ~]# yum install rh-dotnetcore11
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package rh-dotnetcore11-1.0-1.el7.x86_64 already installed and latest version
Nothing to do
What instructions does one follow to use Red Hat Enterprise Linux 7.3 to build, test, run and publish ASP.NET Core application that was created with Visual Studio 2017? .

So it looks like rh-dotnetcore11 doesn't have the latest released version of .NET core command line.
It doesn't. The original release of .NET Core 1.0 had an RC version of CLI (or the SDK, if you will). This was packaged as rh-dotnetcore10 (and later an updated version was rh-dotnetcore11).
Due to compatibility requirements, RHEL packages can not break the command line interface and API.
The 1.0 SDK changed how the command line behaves and the project format; as such it was not suitable for inclusion into RHEL since it would break people's existing workflow and require migration from project.json to csproj.
As such, the RHEL packages contain the latest APIs (corefx and/or coreclr) but the older RC-era SDK.
What instructions does one follow to use Red Hat Enterprise Linux 7.3 to build, test, run and publish ASP.NET Core application that was created with Visual Studio 2017?
Unfortunately, there's no good path forward right now. Some options include:
Using an upstream install of dotnet, something which won't be supported by Red Hat since it's not the official Red Hat package: https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh
Use the RC version of the SDK on Windows, Visual Studio 2015 (2017 doesn't support project.json) and rh-dotnetcore11 on RHEL.
Wait a bit for 2.0 (hopefully releases soon) which should have the new SDK since Red Hat does not aim for compatibility between 1.0 and 2.0.

Related

Self-Hosted GitLab Microsoft.NETCore.App version 6.0.0

We have a self-hosted Gitlab instance (version 14.8) that needs to run a pipeline.
In the .gitlab-ci.yml file I have image : mcr.microsoft.com/dotnet/sdk:6.0
My application is .NET 6.0. I get error: The framework 'Microsoft.NETCore.App', version '6.0.0' was not found.
When running this command:
reportgenerator -reports:"AWS.ServiceTests\TestResults\**\coverage.cobertura.xml" -targetdir:"AWS.ServiceTests\TestResults\coveragereport" -reporttypes:Html
Do I go about to install it from the Linux server that hosts GitLab?
I also tried to install .NET 6 using the BeforeScript option (inside .gitlab-ci.yml) but no luck.

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!!

npm cannot find SDK version from global.json

I'm in the thick of trying to get up-to-speed on asp.net core / npm / react using this as a base project template:
https://github.com/jonmcquade/aspnetcore-react-redux#local-no-docker
I originally ran into troubles once trying this command:
dotnet build -c Release -o ./app
The error I was seeing:
A compatible SDK version for global.json version: [2.1.0] from
[global.json] was not found Did you mean to run dotnet SDK commands?
Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
I had the specific versions in the documentation installed and I have installed the latest versions, both x64 and x86 platforms.
I now also get this error running the npm install command or the dotnet --version command, yet I have SDKs installed.
It feels like the machine configuration has become broken somehow. I seem to have gotten into a bit of a version pickle trying to get the dotnet build command working and now even NPM isn't working.
Global.json is:
{
"sdk": { "version": "2.1.0" }
}
And the .csproj file contains:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.0-preview1-26216-03</RuntimeFrameworkVersion>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<IsPackable>false</IsPackable>
<AssemblyName>FlightSearch</AssemblyName>
<RootNamespace>FlightSearch</RootNamespace>
<ApplicationIcon>ClientApp\favicon.ico</ApplicationIcon>
<Authors>Jon McQuade</Authors>
<Company>ACME Freelancing, Inc.</Company>
<StartupObject></StartupObject>
<Product>Flight Search</Product>
<Description>ASP .NET Core 2.1 MVC SPA with React and Redux</Description>
<RepositoryUrl>http://github.com/jonmcquade/aspnetcore-react-redux</RepositoryUrl>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
<OutputType>Exe</OutputType>
<Version>2.1</Version>
</PropertyGroup>
What am I missing to get this working?
Are there some machine configuration issues that I can check? Maybe environment variables? I've tried running a repair using the installers but this doesn't address the issue.
The global.json specifies the SDK version of .NET Core that is being used to build your application. This has little to do with the .NET Core Runtime version that you want to run your application with.
Your application is a netcoreapp2.1, so you are running the .NET Core 2.1 Runtime. The earliest SDK Version for that is 2.1.300.
Since that is the latest .NET Core version, you actually don’t need to use a global.json at all: Just delete the file from your project and the tooling should use the latest version which is 2.1.300-rc1 on your machine.
If you're running into this issue on OSX you can fix the issue thusly:
which dotnet
ls + the output from the previous command
You should now see something like:
/usr/local/share/dotnet/dotnet
The directory that has your dotnet binary should also have a directory called sdk, so for the above example you can run ls /usr/local/share/dotnet/sdk, which should output a directory with your current version number. In my case that is 2.1.403 (there may be a better way to get the version number, but I was unable to run dotnet --version without specifying the correct sdk)
If I now open the global.json file in my app's root directory and change the sdk version to "2.1.403-osx-gs-x64", I should now be able to run dotnet command such as dotnet run from within my project.
Just make sure the required SDK version is installed in your machine. On your error, it's .NET core 2.1.0. You don't need the global.json file anymore.

Did `dnu restore` replaced `dotnet restore` on yeoman generator-aspnet?

I have ASP.NET Core (v1.0.0-preview2-003131) installed on my macOS Sierra, and installed yeoman generator-aspnet today(11/26/16). From my cli, I ran yo aspnet and created my WebApplication but the options shown to use were dnu restore, dnu build, dnx . kestrel.
What happened to dotnet restore option? I even tried to run dotnet restore but it kept on looking for dnu.
No, DNU is part of the old DNX which was used up until rc1. RC2 and newer are based on dotnet-cli and the dotnet commands.
DNX isn't maintained anymore and shouldn't be use anymore. Just use the dotnet commands, ignoring what that generator says and report the issue here.

"dotnet new" command fails on fresh installation of OS X 10.11.6 OS X El Capitan

I have installed the dotnet-core for OS X using the dotnet-osx-x64.1.0.0.pkg from the official download section. - https://www.microsoft.com/net/download
Running "dotnet new" command gives the below output
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
How to create the basic .net-core project?
I have run the below commands on the user directory without success
echo 'export PATH="$PATH:/usr/local/share/dotnet"' >> ~/.bashrc
and
Created a vi .bash_profile and inserted the below command
export
PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/dotnet
Still the below command fails
dotnet new
This is the version of the .net-core I have
dotnet --version
gives below output
Microsoft .NET Core Shared Framework Host
Version : 1.0.1
Build : cee57bf6c981237d80aa1631cfe83cb9ba329f12
dotnet-osx-x64.1.0.0.pkg is the package containing just .NET Core, basically the runtime.
In order to develop applications, you need the .NET Core SDK. This is also what the error message you see says:
Did you mean to run dotnet SDK commands? Please install dotnet SDK […]
The download website also explains the difference as follows:
You probably only need to download one of these:
.NET Core SDK = Develop apps with .NET Core and the SDK+CLI (Software Development Kit/Command Line Interface) tools
.NET Core = Run apps with the .NET Core runtime
So, just download the .NET Core SDK package for your platform instead. For mac OS, this currently is dotnet-dev-osx-x64.1.0.0-preview2-003121.pkg.
You can also just follow the instructions on the .NET Core quickstart page which gives you detailed step-by-step instructions on how to get .NET Core running properly.