Using Zeus with C# .Net Core

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Using Zeus with C# .Net Core

Post by jussij »

Installation
1. Download .Net Core SDK from here: https://dotnet.microsoft.com/download/dotnet-core

In this example the Windows x64 version of the SDK 5.0.102 was downloaded and installed.
net-core.png
net-core.png (121.88 KiB) Viewed 15572 times
2. After running the installer start the Zeus IDE and check the installation by using the Tools, DOS Command Line menu to run the following command:

Code: Select all

dotnet --info
Running that command should result in the following output:
.NET SDK (reflecting any global.json):
Version: 5.0.102
Commit: 71365b4d42

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.102\
...
Creating a Test Project

1. Using the Tools, Language Shells, Command Prompt menu to open up a command prompt.

2. Navigate to the directory in which the new project will be created, for example:

Code: Select all

C:\>md \Projects
C:\>cd \Projects
3. Run this new command to create a new console application:

Code: Select all

dotnet new console -o TestConsole
NOTE: To create different types of projects (i.e. WinForms, ASP.Net etc.) refer to the different new command options found here.
You can also get the list of projects using this command line:

Code: Select all

c:\Projects>dotnet new
This will result in output similar to this:

Code: Select all

The 'dotnet new' command creates a .NET project based on a template.

Common templates are:
Template Name         Short Name    Language    Tags
--------------------  ------------  ----------  -------------------
ASP.NET Core Web App  razor,webapp  [C#]        Web/MVC/Razor Pages
Blazor Server App     blazorserver  [C#]        Web/Blazor
Class Library         classlib      [C#],F#,VB  Common/Library
Console App           console       [C#],F#,VB  Common/Console
Windows Forms App     winforms      [C#],VB     Common/WinForms
WPF Application       wpf           [C#],VB     Common/WPF

An example would be:
   dotnet new console

Display template options with:
   dotnet new console -h
Display all installed templates with:
   dotnet new --list
Display templates available on NuGet.org with:
   dotnet new web --search
This new command should result in the following output:
Welcome to .NET 5.0!
---------------------
SDK Version: 5.0.102

Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.

Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on TestConsole\TestConsole.csproj...
Determining projects to restore...
Restored C:\Projects\TestConsole\TestConsole.csproj (in 42 ms).
Restore succeeded.
This should have created a new project folder as shown below:

Code: Select all

C:\Projects>dir
 Volume in drive C is Windows
 Volume Serial Number is 3690-9A91

 Directory of C:\Projects

19/01/2021  12:01 PM    <DIR>          .
19/01/2021  12:01 PM    <DIR>          ..
19/01/2021  12:01 PM    <DIR>          TestConsole
               0 File(s)              0 bytes
               3 Dir(s)  128,789,917,696 bytes free
Building the TestConsole Project

1. Using the same Zeus IDE command shell, build the project use the following commands:

Code: Select all

cd \Projects\TestConsole
dotnet build
This should result in the following output:
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Determining projects to restore...
All projects are up-to-date for restore.
TestConsole -> C:\projects\TestConsole\bin\Debug\net5.0\TestConsole.dll

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.42
2. To run the resulting TestConsole.dll file using the following command:

Code: Select all

dotnet run
This should result in the following output:
Hello World!
Creating a Zeus Workspace
As described here a Zeus Workspace can be used to help manage the code base.

To create a workspace do the following:
  • Use the Zeus Workspace, Import menu.
  • In the resulting file open dialog select the *.csproj filter.
  • Select the TestConsole.csproj
These steps will create Zeus workspace for that .Net Core project:

Setting up the C# Language Server
To setup the C# language server follow the instructions found here: https://www.zeusedit.com/lsp/cs-dls.html

Zeus will use the C# language server for code completion, code navigation and tooltip information.
net-lsp.png
net-lsp.png (173.76 KiB) Viewed 15572 times
Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Re: Using Zeus with C# .Net Core

Post by jussij »

Creating a Self-contained Application

.NET Core allows you to create a Self-contained application to help with deployment. This approach will reduce the number of assemblies need to run the application and also eliminates the need to install the .net framework on the target machine as the runtime is included in the executable bundle.

Some of the advantages of using this approach include:
  • No need to installed .NET Core on a target machine
  • Applications using different .NET Core versions can run on the same machine
Naturally these advantages do come with the cost of a bigger executable size.

To create self-contained application run following command:

Code: Select all

dotnet publish -c Release -r win10-x64 /p:PublishSingleFile=true
To remove un-used assembly the following command can be used:

Code: Select all

dotnet publish -c Release -r win10-x64 /p:PublishSingleFile=true /p:PublishTrimmed=true
Running these command will create a publish folder and that folder will contain all the artifacts needed to run the application.
Post Reply