$ dotnet new --install Terminal.Gui.templates
$ dotnet new tui -n test001
$ cd test001
$ dotnet run
tutorials, tips, tricks, commands, programming, linux, windows, database, sql, python, programming language, Fedora, drawing, painting, tutorial, tutorials
Wednesday, July 26, 2023
Fedora 39 : First test with C# and Terminal.Gui.templates.
Sunday, February 7, 2021
Fedora 33 : C# and Google A.P.I .
[root@desk mythcat]# dnf install nuget
...
Installed:
nuget-2.8.7-11.fc33.x86_64
Complete!
Use this command to install it:
[mythcat@desk CSharpProjects]$ nuget install Google.Apis.Discovery.v1
Attempting to resolve dependency 'Google.Apis (= 1.10.0)'.
Attempting to resolve dependency 'Google.Apis.Core (≥ 1.10.0)'.
...
Attempting to resolve dependency 'Google.Apis (≥ 1.49.0)'.
'Google.Apis' already has a dependency defined for 'Google.Apis.Core'.
Create a basic C# project and test it:
[mythcat@desk CSharpProjects]$ mkdir booksAPI && cd booksAPI
[mythcat@desk booksAPI]$ dotnet new console
Getting ready...
...
[mythcat@desk booksAPI]$ dotnet run
Hello World!
Add Google A.P.I. to this project:
[mythcat@desk booksAPI]$ dotnet add package Google.Apis.Discovery.v1 --version 1.49.0
Determining projects to restore...
log : Restored /home/mythcat/CSharpProjects/booksAPI/booksAPI.csproj (in 8.86 sec).
Change the default project source code with this example and add your Google key:
using System;
using System.Threading.Tasks;
using Google.Apis.Discovery.v1;
using Google.Apis.Discovery.v1.Data;
using Google.Apis.Services;
namespace booksAPI
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine("Discovery API Sample");
Console.WriteLine("====================");
try
{
new Program().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("ERROR: " + e.Message);
}
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
private async Task Run()
{
// Create the service.
var service = new DiscoveryService(new BaseClientService.Initializer
{
ApplicationName = "Discovery Sample",
ApiKey="...",
});
// Run the request.
Console.WriteLine("Executing a list request...");
var result = await service.Apis.List().ExecuteAsync();
// Display the results.
if (result.Items != null)
{
foreach (DirectoryList.ItemsData api in result.Items)
{
Console.WriteLine(api.Id + " - " + api.Title);
}
}
}
}
}
I used my key and this is the result of the run project:
[mythcat@desk booksAPI]$ dotnet run
Discovery API Sample
====================
Executing a list request...
abusiveexperiencereport:v1 - Abusive Experience Report API
acceleratedmobilepageurl:v1 - Accelerated Mobile Pages (AMP) URL API
accessapproval:v1 - Access Approval API
accesscontextmanager:v1beta - Access Context Manager API
...
Tuesday, January 19, 2021
Fedora 33 : Create a simple GUI Button on Unity 3D.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class create_button : MonoBehaviour {
void OnGUI()
{
if (GUI.Button(new Rect(10, 10, 300, 20), "Test - Dynamically button"))
{
Debug.Log("Test button");
}
}
}
Thursday, December 3, 2020
Fedora 33 : Create a simple AvaloniaUI window.
[mythcat@desk CSharpProjects]$ git clone https://github.com/AvaloniaUI/avalonia-dotnet-templates --recursive
Cloning into 'avalonia-dotnet-templates'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 379 (delta 14), reused 19 (delta 7), pack-reused 342
Receiving objects: 100% (379/379), 147.23 KiB | 881.00 KiB/s, done.
Resolving deltas: 100% (202/202), done.
[mythcat@desk CSharpProjects]$ ls
aspnetapp avalonia-dotnet-templates HelloWorld myapp001 MyGame001 Todo
[mythcat@desk CSharpProjects]$ dotnet new --install avalonia-dotnet-templates
...
[mythcat@desk CSharpProjects]$ dotnet new avalonia.app -o MyAppAvalonia
The template "Avalonia .NET Core App" was created successfully.
[mythcat@desk CSharpProjects]$ cd MyAppAvalonia/
[mythcat@desk MyAppAvalonia]$ dotnet add package Avalonia
...
[mythcat@desk MyAppAvalonia]$ dotnet add package Avalonia.Desktop
...
[mythcat@desk MyAppAvalonia]$ ls
App.xaml App.xaml.cs MainWindow.xaml MainWindow.xaml.cs MyAppAvalonia.csproj nuget.config Program.cs
[mythcat@desk MyAppAvalonia]$ dotnet publish --configuration Release --runtime fedora.33-x64 --self-contained false
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 3.86 sec for /home/mythcat/CSharpProjects/MyAppAvalonia/MyAppAvalonia.csproj.
MyAppAvalonia -> /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/fedora.33-x64/MyAppAvalonia.dll
MyAppAvalonia -> /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/fedora.33-x64/publish/
[mythcat@desk MyAppAvalonia]$ dotnet /home/mythcat/CSharpProjects/MyAppAvalonia/bin/Release/netcoreapp3.0/
fedora.33-x64/publish/MyAppAvalonia.dll
Monday, November 30, 2020
Fedora 33 : Build and publish with .NET Core SDK .
Let's go to the project and get some infos:
[mythcat@desk ~]$ cd CSharpProjects/
[mythcat@desk CSharpProjects]$ cd MyGame001/
[mythcat@desk MyGame001]$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.109
Commit: 32ced2d411
Runtime Environment:
OS Name: fedora
OS Version: 33
OS Platform: Linux
RID: fedora.33-x64
Base Path: /usr/lib64/dotnet/sdk/3.1.109/
Host (useful for support):
Version: 3.1.9
Commit: 774fc3d6a9
.NET Core SDKs installed:
3.1.109 [/usr/lib64/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The next command will create MyGame001.dll.
[mythcat@desk MyGame001]$ dotnet publish --configuration Release --runtime fedora.33-x64 --self-contained false
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 50.58 ms for /home/mythcat/CSharpProjects/MyGame001/MyGame001.csproj.
MyGame001 -> /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/MyGame001.dll
MyGame001 -> /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/publish/
Now you can run it with dotnet command:
[mythcat@desk MyGame001]$ dotnet /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/MyGame001.dll
You can simply run it like an Linux application:
[mythcat@desk MyGame001]$ /home/mythcat/CSharpProjects/MyGame001/bin/Release/netcoreapp3.1/fedora.33-x64/publish/MyGame001
Saturday, November 28, 2020
Fedora 33 : Install and test with MonoGame .NET library .
Today I tested with Fedora 33.
First let's install this templates for .NET Core CLI and the Rider IDE.:
[mythcat@desk ~]$ dotnet new --install MonoGame.Templates.CSharp
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.109
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Getting ready...
Restore completed in 2.76 sec for /home/mythcat/.templateengine/dotnetcli/v3.1.109/scratch/restore.csproj.
...
Install MGCB Editor is a tool for editing .mgcb files:[mythcat@desk ~]$ dotnet tool install --global dotnet-mgcb-editor
You can invoke the tool using the following command: mgcb-editor
Tool 'dotnet-mgcb-editor' (version '3.8.0.1641') was successfully installed.
[mythcat@desk ~]$ mgcb-editor --register
Installing icon...
Installation complete!
Installing mimetype...
gtk-update-icon-cache: No theme index file.
Installation complete!
Installing application...
Installation complete!
Registered MGCB Editor!
Install C# extension for code editor:[mythcat@desk ~]$ code --install-extension ms-dotnettools.csharp
Installing extensions...
Extension 'ms-dotnettools.csharp' is already installed.
The next step is to create new MonoGame projects:
[mythcat@desk ~]$ cd CSharpProjects/
[mythcat@desk CSharpProjects]$ dotnet new mgdesktopgl -o MyGame001
The template "MonoGame Cross-Platform Desktop Application (OpenGL)" was created successfully.
An update for template pack MonoGame.Templates.CSharp::3.8.0.1641 is available.
install command: dotnet new -i MonoGame.Templates.CSharp::3.8.0.1641
I run the default template and working well:
[mythcat@desk CSharpProjects]$ cd MyGame001
[mythcat@desk MyGame001]$ ls
app.manifest Content Game1.cs Icon.bmp Icon.ico MyGame001.csproj Program.cs
[mythcat@desk MyGame001]$ dotnet run Program.cs
The default source code from Program.cs file is this:using System;
namespace MyGame001
{
public static class Program
{
[STAThread]
static void Main()
{
using (var game = new Game1())
game.Run();
}
}
}
Saturday, October 17, 2020
Fedora 32 : Visual Code and C# on Fedora distro.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/
vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" >
/etc/yum.repos.d/vscode.repo'
Then use dnf to check and install this editor.#dnf check-update
#dnf install code
Use Extensions button or Ctrl+Shift+X keys to open in the left side area and intall the C# extension from Microsoft by pressing the Install button, see:Created a folder named CSharpProjects and using the linux terminal execute the following command:
[mythcat@desk CSharpProjects]$ dotnet new mvc -au None -o aspnetapp
The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft,
see https://aka.ms/aspnetcore/3.1-third-party-notices for details.
Processing post-creation actions...
Running 'dotnet restore' on aspnetapp/aspnetapp.csproj...
Restore completed in 112.76 ms for /home/mythcat/CSharpProjects/aspnetapp/aspnetapp.csproj.
Restore succeeded.
[mythcat@desk CSharpProjects]$ cd aspnetapp/
[mythcat@desk aspnetapp]$ code .
This command will open the Visual Code.
At this point, in the aspnetapp folder is an ASP.NET project open in Visual Code.
You can run this project with command:
[mythcat@desk aspnetapp]$ dotnet run
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {4c284989-9a5d-4ea7-89e2-a383828fd7ab} may be persisted
to storage in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/mythcat/CSharpProjects/aspnetapp
You can open the https://localhost:5001/ and see the default Welcome page from ASP.NET.
Friday, October 2, 2020
Fedora 32 : Can be better? part 015.
In the evening I can spend my time with Fedora 32.
In the last few days I studied GTK # a bit.
I thought it would be useful for Linux users and those who use the language of the FASM assembler to have an editor.
Tonight I created this simple project this simple project named fasm_editor.
The objectives of this project are:
- creating a functional editor;
- implementation of running and compilation requirements;
- settings specific to the Linux operating system;
I believe that this way Fedora Linux can be improved and become better.
Wednesday, September 30, 2020
Fedora 32 : Can be better? part 014.
The GTK documentation for C # is not very up to date, I tried to use a button to change a label and I failed first time. The Fedora team could improve this to develop the development side. Here's what I've managed to do so far with GTK.
I fixed the source code with this, but I would have preferred a better method:
my_Button.Clicked += delegate {
my_Label.Text = "Use delegate!";
};
Mono is a free and open source implementation of the .NET Framework.
The most popular build tool for Mono is NAnt.
NUnit is very useful for test driven development.
[root@desk mythcat]# dnf install mono-devel
Last metadata expiration check: 0:15:26 ago on Wed 30 Sep 2020 09:04:30 PM EEST.
Package mono-devel-6.6.0-8.fc32.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@desk mythcat]# dnf install nant
...
Installed:
log4net-2.0.8-10.fc32.x86_64 nant-1:0.92-25.fc32.x86_64
nunit2-2.6.4-24.fc32.x86_64
Complete!
[root@desk mythcat]# dnf install nunit nunit-gui
Last metadata expiration check: 0:02:09 ago on Wed 30 Sep 2020 09:27:18 PM EEST.
No match for argument: nunit-gui
Error: Unable to find a match: nunit-gui
Installing MonoDevelop:
[root@desk mythcat]# dnf install monodevelop
...
Installed:
ORBit2-2.14.19-23.fc32.x86_64
gamin-0.1.10-36.fc32.x86_64
gnome-desktop-sharp-2.26.0-36.fc31.x86_64
gnome-sharp-2.24.2-25.fc32.x86_64
gnome-vfs2-2.24.4-30.fc32.x86_64
gnome-vfs2-common-2.24.4-30.fc32.noarch
gtk-sharp2-2.12.45-11.fc32.x86_64
gtk-sharp2-devel-2.12.45-11.fc32.x86_64
gtksourceview2-2.11.2-31.fc32.x86_64
libIDL-0.8.14-21.fc32.x86_64
libbonobo-2.32.1-18.fc32.x86_64
libbonoboui-2.24.5-18.fc32.x86_64
libgnome-2.32.1-20.fc32.x86_64
libgnome-keyring-3.12.0-19.fc32.x86_64
libgnomecanvas-2.30.3-19.fc32.x86_64
libgnomeui-2.24.5-21.fc32.x86_64
mono-addins-1.1-13.fc32.x86_64
monodevelop-5.10.0-17.fc32.x86_64
vte-0.28.2-31.fc32.x86_64
Complete!
Install the .NET Core. This is a general-purpose, modular, cross-platform and open-source development Platform.
[root@desk mythcat]# dnf copr enable @dotnet-sig/dotnet
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.
...
Do you really want to enable copr.fedorainfracloud.org/@dotnet-sig/dotnet? [y/N]: y
Repository successfully enabled.
[root@desk mythcat]# dnf install dotnet
Copr repo for dotnet owned by @dotnet-sig 5.4 kB/s | 3.3 kB 00:00
Package dotnet-3.1.108-1.fc32.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Let's start with a GTK project using the MonoDevelop I.D.E.
[mythcat@desk ProjectsCSharp]$ monodevelop
I use a new solution from .NET with GTK# 2.0 Project template.
The default source code is this:
using System;
using Gtk;
namespace MonoDevelopGTK_001
{
class MainClass
{
public static void Main (string[] args)
{
Application.Init ();
MainWindow win = new MainWindow ();
win.Show ();
Application.Run ();
}
}
}
The result is an simple window form.
For a complex form with entry ,label and one button, you can see the next example:
using System;
using Gtk;
namespace MonoDevelopGTK_001
{
class MainClass
{
public static void Main (string[] args)
{
// define here Entry and Button
Entry name;
Button my_Button;
Application.Init ();
MainWindow win = new MainWindow ();
// change the size of window
win.SetDefaultSize (640, 480);
// this will close application
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
// use of VBox or HBox
VBox global_vbox = new VBox();
win.Add(global_vbox);
name = new Entry();
global_vbox.PackStart(name, false, false, 0);
win.Add(name);
VBox label_vbox = new VBox();
global_vbox.Add (label_vbox);
//Define here a label and put some text in it.
Label my_Label = new Label();
my_Label.Text = "Hello World!";
label_vbox.PackStart(my_Label, false, false, 0);
//Add the label to the form
win.Add(my_Label);
VBox button_vbox = new VBox();
global_vbox.Add (button_vbox);
my_Button = new Button("Ok!");
my_Button.Clicked += OnButtonClicked;
button_vbox.PackStart(my_Button, false, false, 0);
win.Add(my_Button);
// ShowAll is used to see all labels, buttons
win.ShowAll();
//win.Show ();
Application.Run ();
}
public static void OnButtonClicked (object obj, EventArgs args)
{
//Label my_Label = obj as Gtk.Label;
Console.WriteLine ("Button Clicked !");
}
static void Window_Delete (object obj, DeleteEventArgs args)
{
Application.Quit ();
args.RetVal = true;
}
}
}
Friday, August 7, 2020
Fedora 32 : First example with C# on Fedora distro.
[mythcat@desk ~]$ sudo dnf copr enable @dotnet-sig/dotnet
[sudo] password for mythcat:
Enabling a Copr repository. Please note that this repository is not part
of the main distribution, and quality may vary.
The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
,
and packages are not held to any quality or security level.
Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.
Do you really want to enable copr.fedorainfracloud.org/@dotnet-sig/dotnet? [y/N]: y
Repository successfully enabled.
Install the .NET Core package:
[mythcat@desk ~]$ sudo dnf install dotnet
Copr repo for dotnet owned by @dotnet-sig 42 kB/s | 59 kB 00:01
Dependencies resolved.
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
dotnet x86_64 3.1.106-1.fc32 updates 11 k
Installing dependencies:
aspnetcore-runtime-3.1 x86_64 3.1.6-1.fc32 updates 6.2 M
aspnetcore-targeting-pack-3.1 x86_64 3.1.6-1.fc32 updates 945 k
dotnet-apphost-pack-3.1 x86_64 3.1.6-1.fc32 updates 70 k
dotnet-host x86_64 3.1.6-1.fc32 updates 104 k
dotnet-hostfxr-3.1 x86_64 3.1.6-1.fc32 updates 164 k
dotnet-runtime-3.1 x86_64 3.1.6-1.fc32 updates 27 M
dotnet-sdk-3.1 x86_64 3.1.106-1.fc32 updates 41 M
dotnet-targeting-pack-3.1 x86_64 3.1.6-1.fc32 updates 1.8 M
dotnet-templates-3.1 x86_64 3.1.106-1.fc32 updates 1.8 M
netstandard-targeting-pack-2.1 x86_64 3.1.106-1.fc32 updates 1.3 M
Transaction Summary
=================================================================================
Install 11 Packages
Total download size: 79 M
Installed size: 298 M
Is this ok [y/N]:
...
Use this tutorial to install Visual Studio Code.
Press Ctr-P keys to install the C# extension by OmniSharp.
ext install ms-dotnettools.csharp
The last step is to create a application HelloWorld:
[mythcat@desk ~]$ dotnet new console -o HelloWorld
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.106
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Getting ready...
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on HelloWorld/HelloWorld.csproj...
Restore completed in 119.48 ms for /home/mythcat/HelloWorld/HelloWorld.csproj.
Restore succeeded.
You can run it with dotnet run command:
[mythcat@desk ~]$ cd HelloWorld/
[mythcat@desk HelloWorld]$ ls
HelloWorld.csproj obj Program.cs
[mythcat@desk HelloWorld]$ dotnet run Program.cs
Hello World!
Saturday, December 2, 2017
Fedora 27 : Test install with dotnet from microsoft.
The Microsoft team come with RedHat packages version - 7.3 and is an old type of packages.
They show us this old way how to deal with this issue , see this link.
I used this command lines into sudo user:
#rpm --import https://packages.microsoft.com/keys/microsoft.asc
#sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod
\nbaseurl=https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1
\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" >
/etc/yum.repos.d/dotnetdev.repo'
#dnf update
#dnf install libunwind libicu compat-openssl10
#dnf install dotnet-sdk-2.0.2
#dotnet new console -o myApp
#cd myApp
#dotnet run
As you can see the dotnet working well with Fedora 27.I would have preferred a classic dnf installation for reasons of later incompatibility.
This fact only indicates a tangential interest and a clear reason in microsoft capabilities to cover dotnet's area of interest versus linux distributions.