Dotnet new winforms linux

How to create dotnet core WinForms Application using dotnet-cli

NET Core command-line interface (dotnet-cli) is a new NET Core toolset (commands) for developing NET Core Applications. The dotnet-cli toolset provides a list of pre-installed dotnet core project templates from which the user can create various applications as a dotnet core WinForms (Windows Form) application, WPF (Windows Presentation Foundation) application, console application, Web application, and other test applications. The application created with dotnet-cli can be executed on any Windows, Linux, or macOS operating system.

How to create a “dotnet core WinForms (Windows Forms) Application”

The user can use the dotnet new “Windows Forms” or “dotnet new winforms” command from the dotnet-CLI toolset to create a new dotnet core WinForms (Windows Forms) application. The command provides a few options that can be applied as a parameter to tweak the output of the command as shown below :

“dotnet new winforms –no-restore”: This command does not restore the required project dependencies by the WinForms application. Please follow through to read about a few “dotnet new winforms” command usage.

Prerequisite:

.NET Core SDK 3.0 (preview) and above. The current version is .NET Core 5.0 and can be downloaded here.

Command Syntax:

The format of the command is as follows: dotnet new winforms [options]

The details of the available command options can be listed using the –help option as follows:

C:\>dotnet new winforms --help Usage: new [options] Options: -h, --help Displays help for this command. -l, --list Lists templates containing the specified name. If no name is specified, lists all templates. -n, --name The name for the output being created. If no name is specified, the name of the current directory is used. -o, --output Location to place the generated output. -i, --install Installs a source or a template pack. -u, --uninstall Uninstalls a source or a template pack. --nuget-source Specifies a NuGet source to use during install. --type Filters templates based on available types. Predefined values are "project", "item" or "other". --dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation. --force Forces content to be generated even if it would change existing files. -lang, --language Filters templates based on language and specifies the language of the template to create. Windows Forms (WinForms) Application (C#) Author: Microsoft Description: A project for creating a .NET Core Windows Forms (WinForms) Application Options: --langVersion Sets langVersion in the created project file text - Optional --no-restore If specified, skips the automatic restore of the project on create. bool - Optional Default: false / (*) true * Indicates the value used if the switch is provided without a value.

Command Usage – dotnet new winforms:

1. “dotnet new winforms”

The command creates a new “NET Core Windows Forms” project. The name of the project is not specified in the command so by default the project name will be the same as the directory where the command was executed, additionally, the command will also restore the dependency required by the project implicitly. The default language is C#, so the project created will be of C# type. The list of the file that will be created using the mentioned commands is given below.

C:\Temp>dotnet new winforms The template "Windows Forms (WinForms) Application" was created successfully. Processing post-creation actions. Running 'dotnet restore' on C:\Temp\Temp.csproj. Restore completed in 162.66 ms for C:\Temp\Temp.csproj. Restore succeeded.

Files and folders created by the command:

C:\temp>dir Volume in drive C is OSDisk Volume Serial Number is 8053-FAC8 Directory of C:\temp 06/17/2019 05:06 PM . 06/17/2019 05:06 PM .. 06/17/2019 05:06 PM 387 Form1.cs 06/17/2019 05:06 PM 1,234 Form1.Designer.cs 06/17/2019 05:06 PM 5,817 Form1.resx 06/17/2019 05:06 PM obj 06/17/2019 05:06 PM 527 Program.cs 06/17/2019 05:06 PM 242 temp.csproj 06/17/2019 05:06 PM xlf

2.”dotnet new winforms –name Hello”

The command creates a new “NET Core Windows Forms” project having the name of Hello.csproj. The command creates a Hello directory only if doesn’t exist and then creates the boilerplate files in the directory, additionally, the command also restores the dependency required by the project.

C:\>dotnet new winforms --name Hello The template "Windows Forms (WinForms) Application" was created successfully. Processing post-creation actions. Running 'dotnet restore' on Hello\Hello.csproj. Restore completed in 96.53 ms for C:\Hello\Hello.csproj. Restore succeeded.

Files and folders created by the command:

C:\>cd Hello C:\Hello>dir Volume in drive C is OSDisk Volume Serial Number is 8053-FAC8 Directory of C:\Hello 06/17/2019 05:09 PM . 06/17/2019 05:09 PM .. 06/17/2019 05:09 PM 388 Form1.cs 06/17/2019 05:09 PM 1,235 Form1.Designer.cs 06/17/2019 05:09 PM 5,817 Form1.resx 06/17/2019 05:09 PM 242 Hello.csproj 06/17/2019 05:09 PM obj 06/17/2019 05:09 PM 528 Program.cs 06/17/2019 05:09 PM xlf

3. “dotnet new winforms –name Hello –no-restore”

The command creates a new “NET Core Windows Forms” project having the name of Hello. The command creates a Hello directory only if doesn’t exist and then creates the boilerplate files in the directory, the command does not restore the dependency required by the project. The output of the command is as follows:

C:\>dotnet new winforms --name Hello --no-restore The template "Windows Forms (WinForms) Application" was created successfully. C:\>cd Hello C:\Hello>dir Volume in drive C is OSDisk Volume Serial Number is 8053-FAC8 Directory of C:\Hello 06/17/2019 05:13 PM . 06/17/2019 05:13 PM .. 06/17/2019 05:13 PM 388 Form1.cs 06/17/2019 05:13 PM 1,235 Form1.Designer.cs 06/17/2019 05:13 PM 5,817 Form1.resx 06/17/2019 05:13 PM 242 Hello.csproj 06/17/2019 05:13 PM 528 Program.cs 06/17/2019 05:13 PM xlf

4. “dotnet new winforms –name Hello –languageVersion 7.0”

The command creates a new “NET Core Windows Forms” project having the name of Hello. The command creates a Hello directory only if doesn’t exist and then creates the boilerplate files and directory, additionally, the command also restores the dependency required by the project. The command creates the project specific to C# 7.0 (version). The details can be found in the Hello.csproj file.

C:\>dotnet new winforms --name Hello --langVersion 7.0 The template "Windows Forms (WinForms) Application" was created successfully. Processing post-creation actions. Running 'dotnet restore' on Hello\Hello.csproj. Restore completed in 108.97 ms for C:\Hello\Hello.csproj. Restore succeeded.

Content of Hello.csproj file: LangVersion tag contains 7.0

C:\Temp\dotnet\Hello>type Hello.csproj  WinExe netcoreapp3.0 7.0 true  

I hope you found this post on how to create a WinForms Application using dotnet-cli. Thanks for visiting. Cheers .

Читайте также:  Rtf чем открыть linux

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] dotnet new winforms #13231

[Linux] dotnet new winforms #13231

Comments

dotnet new winforms for Linux:

dotnet new winforms -o HelloWinForm The template "Windows Forms (WinForms) Application" was created successfully. Processing post-creation actions. Running 'dotnet restore' on HelloWinForm/HelloWinForm.csproj. Determining projects to restore. /home/zhaixiang/dotnet-sdk-3.1.401-linux-x64/sdk/3.1.401/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(59,5): error NETSDK1100: Windows is required to build Windows desktop applications. [/home/zhaixiang/HelloWinForm/HelloWinForm.csproj] Restore failed. Post action failed. Description: Restore NuGet packages required by this project. Manual instructions: Run 'dotnet restore' 

So is it better to hide winforms or wpf for dotnet new —help ?

The text was updated successfully, but these errors were encountered:

Any suggestion about Desktop UI application development for Linux?

@xiangzhai, this has been addressed in .NET 5. We do not get those templates with 5.0 RC1:

# bash on macOS x64 # install dotnet 5.0 RC1 at custom location $ mkdir ~/.dotnet5 $ curl -sSL https://aka.ms/dotnet/net5/rc1/Sdk/dotnet-sdk-osx-x64.tar.gz | tar xzf - -C ~/.dotnet5 # setup NuGet feed for .NET 5 preview $ cat > NuGet.config  EOF      EOF $ ~/.dotnet5/dotnet new -h /snip Templates Short Name Language Tags -------------------------------------------- -------------- ------------ ---------------------- Console Application console [C#], F#, VB Common/Console Class library classlib [C#], F#, VB Common/Library Worker Service worker [C#], F# Common/Worker/Web Unit Test Project mstest [C#], F#, VB Test/MSTest NUnit 3 Test Project nunit [C#], F#, VB Test/NUnit NUnit 3 Test Item nunit-test [C#], F#, VB Test/NUnit xUnit Test Project xunit [C#], F#, VB Test/xUnit Razor Component razorcomponent [C#] Web/ASP.NET Razor Page page [C#] Web/ASP.NET MVC ViewImports viewimports [C#] Web/ASP.NET MVC ViewStart viewstart [C#] Web/ASP.NET Blazor Server App blazorserver [C#] Web/Blazor Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly ASP.NET Core Empty web [C#], F# Web/Empty ASP.NET Core Web App (Model-View-Controller) mvc [C#], F# Web/MVC ASP.NET Core Web App webapp [C#] Web/MVC/Razor Pages ASP.NET Core with Angular angular [C#] Web/MVC/SPA ASP.NET Core with React.js react [C#] Web/MVC/SPA ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA Razor Class Library razorclasslib [C#] Web/Razor/Library ASP.NET Core Web API webapi [C#], F# Web/WebAPI ASP.NET Core gRPC Service grpc [C#] Web/gRPC dotnet gitignore file gitignore Config global.json file globaljson Config NuGet Config nugetconfig Config Dotnet local tool manifest file tool-manifest Config Web Config webconfig Config Solution File sln Solution Protocol Buffer File proto Web/gRPC Examples: dotnet new mvc --auth Individual dotnet new nunit-test dotnet new --help

and trying to create the app gives:

$ ~/.dotnet5/dotnet new winforms -o HelloWinForms Couldn't find an installed template that matches the input, searching online for one that does. /snip $ ~/.dotnet5/dotnet new wpf -o HelloWPF Couldn't find an installed template that matches the input, searching online for one that does. /snip

Источник

how to install and use Winforms in VSCode on Linux?

(.NET Core Version 3.0.103 (Commit: b7ef045669), Platform/OS: ubuntu linux 18.04-x64, Winforms branch version (date): Thu Mar 26 07:37:13 2020 -0700, VSCode 1.43.2) I cloned current version of Winforms from Github, tried to use appropriate installation script (build.sh) but finally got only error message (I think it’s a bug). Possibly someone was more succefull? (Even though Winforms Designer doesn’t still work in VSCode on Linux as I got from documentation there should be possibility to create Windows Form Application templates from console, port existing application from .NET Framework to .NET Core and so on). So can anyone share your experience about this?

1 Answer 1

Winforms is currently a Windows-only technology in the .NET Core runtime. I haven’t seen an instance of someone circumvening this limitation.

.NET Core (and in the future .NET 5 that is built on top of .NET Core) will be the future of .NET. We are committed to support .NET Framework for years to come, however it will not be receiving any new features, those will only be added to .NET Core (and eventually .NET 5). To improve Windows desktop stacks and enable .NET desktop developers to benefit from all the updates of the future, we brought Windows Forms and WPF to .NET Core. They will still remain Windows-only technologies because there are tightly coupled dependencies to Windows APIs. But .NET Core, besides being cross-platform, has many other features that can enhance desktop applications.

The Mono Project supports Winforms, which can be run on linux, however I’m unaware of how to develop Winforms via Mono on vscode.

Источник

Оцените статью
Adblock
detector