User Tools

Site Tools


notes:tools:netcore

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:tools:netcore [2019/02/08]
leszek
notes:tools:netcore [2020/09/18] (current)
leszek
Line 1: Line 1:
 ====== .NET Core ====== ====== .NET Core ======
  
-<code text> +====dotnet Command====
-dotnet build +
-dotnet build -v n            # set verbosity level to normal +
-dotnet build -f net45        # use a specific target framework; the framework has to be set as <TargetFrameworks> +
-dotnet build /p:Platform=x64 +
-</code>+
  
-Create a console app called 'ConsoleApp':+Create and run a console app called 'ConsoleApp':
 <code text> <code text>
 md ConsoleApp md ConsoleApp
 cd ConsoleApp cd ConsoleApp
 dotnet new console dotnet new console
 +dotnet run
 +</code>
 +
 +Create a console app in a given language and the name 'MyApp':
 +<code text>
 +dotnet new console -lang "F#" --name "MyApp"
 +</code>
 +
 +Specify command-line arguments. Here, we specify four arguments:
 +<code text>
 +dotnet run arg1 arg-2 arg:3 "arg 4"
 </code> </code>
  
Line 27: Line 33:
 cd TestProj cd TestProj
 dotnet new nunit dotnet new nunit
 +
 +dotnet test                      # run a test
 </code> </code>
  
Line 33: Line 41:
 cd TestProj cd TestProj
 dotnet add reference "..\ConsoleApp\ConsoleApp.csproj" dotnet add reference "..\ConsoleApp\ConsoleApp.csproj"
 +</code>
 +
 +Show help:
 +<code text>
 +dotnet --help                    # get help on dotnet commands and options
 +dotnet <command> -h              # get CLI help (output help at the command line)
 +dotnet <command> --help          # the same as dotnet <command> -h
 +dotnet help <command>            # get on-line help
 </code> </code>
  
Line 47: Line 63:
 </code> </code>
  
 +<code text>
 +dotnet build
 +dotnet build -v n            # set verbosity level to normal
 +dotnet build -f net45        # use a specific target framework; the framework has to be set as <TargetFrameworks>
 +dotnet build /p:Platform=x64
 +</code>
  
 dotnet commands: dotnet commands:
 <code text> <code text>
-dotnet --version +dotnet --version                 # determine which version of the .NET Core SDK you have available
-dotnet --help+
 dotnet run                       # build and execute .csproj in the current folder dotnet run                       # build and execute .csproj in the current folder
-dotnet <command> -h              # get CLI help 
-dotnet help <command>            # get on-line help 
 dotnet <command> -v diag         # run diagnostics dotnet <command> -v diag         # run diagnostics
 dotnet add app.csproj reference lib.csproj  # add p2p reference to app.csproj dotnet add app.csproj reference lib.csproj  # add p2p reference to app.csproj
 </code> </code>
 +
 +
 +====Deployment====
  
 <code text> <code text>
Line 68: Line 90:
 dotnet publish -c Release -r ubuntu.16.04-x64 dotnet publish -c Release -r ubuntu.16.04-x64
 </code> </code>
 +
 +====csproj MSBuild====
  
 Multi-targeting: Multi-targeting:
Line 78: Line 102:
 </Project> </Project>
 </code> </code>
 +
 +Enable a specific language version compiler:
 +<code xml>
 +<Project Sdk="Microsoft.NET.Sdk">
 +  <PropertyGroup>
 +    <OutputType>Exe</OutputType>
 +    <TargetFramework>netcoreapp3.0</TargetFramework>
 +    <LangVersion>8.1</LangVersion>
 +  </PropertyGroup>
 +</Project>
 +</code>
 +
 +Values for the [[https://devblogs.microsoft.com/dotnet/an-update-to-c-versions-and-c-tooling/|<LangVersion>]]:
 +^  LangVersion  ^  Description  ^
 +| 7, 7.1, 7.2, 7.3, 8 | Entering a specific version number will use that compiler if it has been installed. |
 +| latestmajor | Uses the highest major number |
 +| latest | Uses the highest major and highest minor number |
 +| preview | Uses the highest available preview version |
 +
 +Your projects must target either netcoreapp3.0 or netstandard2.1 to use the full features of C# 8.0.
 +
 +====Multi-platform Support====
 +
 +<WRAP center round box 60%>
 +Handle platforms that do not support an API using ''%%PlatformNotSupportedException%%''.
 +</WRAP>
  
 Install prerequisites for SCD on Ubuntu: Install prerequisites for SCD on Ubuntu:
Line 98: Line 148:
   * 2.0.7, 2.0.9, 2.1.2   * 2.0.7, 2.0.9, 2.1.2
  
-Links+x86_x64 Cross Tools CommandPrompt for VS 2019: 
 +<code text> 
 +csc -langversion:?           # determine which versions of the C# compiler you have available 
 +</code> 
 + 
 +====Links==== 
   * [[https://apisof.net/|apisof.net]]   * [[https://apisof.net/|apisof.net]]
   * [[https://docs.microsoft.com/en-us/dotnet/|Docs]]   * [[https://docs.microsoft.com/en-us/dotnet/|Docs]]
notes/tools/netcore.1549657952.txt.gz · Last modified: 2020/08/26 (external edit)