VS Code برای توسعه دهندگان ASP.NET Core - قسمت دوم - ایجاد و اجرای اولین برنامه
نویسنده: وحید نصیری
تاریخ: ۱۳۹۶/۰۲/۳۱ ۸:۵
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
C:\>dotnet --version 1.0.1
D:\vs-code-examples\FirstAspNetCoreProject>dotnet new --help
Getting ready...
Template Instantiation Commands for .NET Core CLI.
Usage: dotnet new [arguments] [options]
Arguments:
template The template to instantiate.
Options:
-l|--list List templates containing the specified name.
-lang|--language Specifies the language of the template to create
-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.
-h|--help Displays help for this command.
-all|--show-all Shows all templates
Templates Short Name Language Tags
----------------------------------------------------------------------
Console Application console [C#], F# Common/Console
Class library classlib [C#], F# Common/Library
Unit Test Project mstest [C#], F# Test/MSTest
xUnit Test Project xunit [C#], F# Test/xUnit
ASP.NET Core Empty web [C#] Web/Empty
ASP.NET Core Web App mvc [C#], F# Web/MVC
ASP.NET Core Web API webapi [C#] Web/WebAPI
Solution File sln Solution
Examples:
dotnet new mvc --auth None --framework netcoreapp1.1
dotnet new xunit --framework netcoreapp1.1
dotnet new --help D:\vs-code-examples\FirstAspNetCoreProject>dotnet new mvc --auth None
D:\vs-code-examples\FirstAspNetCoreProject>code .
"terminal.integrated.shell.windows": "cmd.exe"
D:\vs-code-examples\FirstAspNetCoreProject>dotnet run Hosting environment: Production Content root path: D:\vs-code-examples\FirstAspNetCoreProject Now listening on: http://localhost:5000 Application started. Press Ctrl+C to shut down.
The command depends on the dotnet build command to build the code.
The specified framework 'Microsoft.NETCore.App', version '1.1.2' was not found.
"program": "${workspaceRoot}/src/ASPNETCoreIdentitySample/bin/Debug/netcoreapp2.0/ASPNETCoreIdentitySample.dll", Predefined type 'System.Void' is not defined or imported #1855
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Enterprise 2017 15.0.26228.4 - "e:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
2: StandAlone 15.0 - "C:\Users\xyz\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Enterprise 2017 15.0.26228.4 - "e:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" VS Code -> select View->Output -> select "OmniSharp Log"
این مشکل در نگارش 1.13.1 برطرف شدهاست.
It was not possible to find any installed .NET SDKs. Install a .NET SDK from: https://aka.ms/dotnet-download
C:\Program Files (x86)\dotnet
C:\Program Files\dotnet
Located 2 MSBuild instance(s)
1: Visual Studio Enterprise 2019 16.10.31424.327 16.10.2 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
2: StandAlone 17.0.0 - "c:\Users\meysams\.vscode\extensions\ms-dotnettools.csharp-1.23.13\.omnisharp\1.37.12\.msbuild\Current\Bin" Received response for /v2/getcodeactions but could not find request.
"profiles": {
"defaults": {
// Put settings here that you want to apply to all profiles
"startingDirectory": "."
}...
"group": "build"
"group": {
"kind": "build",
"isDefault": true
} public static class AttributesErrorMessages
{
public const string RequiredMessage = "لطفا {0} را وارد نمایید";
public const string MinLengthMessage = "{0} نباید کمتر از {1} کاراکتر باشد";
public const string MaxLengthMessage = "{0} نباید بیشتر از {1} کاراکتر باشد";
public const string RegularExpressionMessage = "{0} را به درستی وارد نمایید";
public const string StringLengthMessage = "{0} باید بین {2} کاراکتر و {1} کاراکتر باشد";
public const string RemoteMessage = "با این {0} قبلا ثبت نام شده است";
} [StringLength(110, MinimumLength = 5, ErrorMessage = AttributesErrorMessages.StringLengthMessage)]
public string TestProp { get; set; } {
"Required":{
"prefix":"required",
"body":[
"[Required(ErrorMessage = AttributesErrorMessages.RequiredMessage)]"
],
"description":"Required attribute"
},
"Max Length":{
"prefix":"maxlength",
"body":[
"[MaxLength(${1:number}, ErrorMessage = AttributesErrorMessages.MaxLengthMessage)]"
],
"description":"Max length attribute"
},
"Min Length":{
"prefix":"minlength",
"body":[
"[MinLength(${1:number}, ErrorMessage = AttributesErrorMessages.MinLengthMessage)]"
],
"description":"Min length attribute"
},
"String Length":{
"prefix":"stringlength",
"body":[
"[StringLength(${1:maximumNumber}, MinimumLength = ${2:minmumNumber}, ErrorMessage = AttributesErrorMessages.StringLengthMessage)]"
],
"description":"String length attribute"
},
"Email Address":{
"prefix":"emailaddress",
"body":[
"[EmailAddress(ErrorMessage = AttributesErrorMessages.RegularExpressionMessage)]"
],
"description":"Email address attribute"
},
"Regular Expression":{
"prefix":"regularexpression",
"body":[
"[RegularExpression(\"${1:patternString}\", ErrorMessage = AttributesErrorMessages.RegularExpressionMessage)]"
],
"description":"Regular expression attribute"
},
"Remote Expression":{
"prefix":"remote",
"body":[
"[Remote(\"${1:action}\", \"${2:controller}\", ErrorMessage = AttributesErrorMessages.RemoteMessage)]"
],
"description":"Remote attribute"
}
} در ادامه یکی از فایلهای #C آنرا گشوده و منتظر شوید تا کار دریافت خودکار بستههای مرتبط با افزونهی #C ایی