using System;
namespace MyNamespace
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, world!");
}
}
}
Console.WriteLine("Hello, World!");
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using StuffTest;
using StuffTest.Data;
using StuffTest.Data.Abstract;
using StuffTest.Data.Repositories;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
var services = builder.Services;
var mappingConfig = new MapperConfiguration(mc => mc.AddProfile(new MappingProfile()));
services.AddSingleton(mappingConfig.CreateMapper());
services
.AddDbContext<StuffContent>(options =>
options.UseSqlite(
"Data Source=mydb.db;",
o => o.MigrationsAssembly("StuffTest")
).EnableSensitiveDataLogging()
);
services.AddScoped<IUserRepository, UserRepository>();
services.AddScoped<IPositionRepository, PositionRepository>();
services
.AddMvc()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "StuffTest API", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = @"JWT Authorization header using the Bearer scheme. \r\n\r\n
Enter 'Bearer' [space] and then your token in the text input below.
\r\n\r\nExample: 'Bearer 12345abcdef'",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement()
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
},
Scheme = "oauth2",
Name = "Bearer",
In = ParameterLocation.Header,
},
new List<string>()
}
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseAuthorization();
app.MapControllers();
app.UseSwagger();
IApplicationBuilder applicationBuilder = app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("v1/swagger.json", "StuffTest API V1");
});
var scope = app.Services.CreateScope();
var ctx = scope.ServiceProvider.GetRequiredService<StuffContent>(); // а вот тут вообще блин
ctx.Database.EnsureCreated();
app.Run();
var ctx = scope.ServiceProvider.GetRequiredService<StuffContent>(); // а вот тут вообще блин
ctx.Database.EnsureCreated();
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
<Using Include="..."/>
dotnet new console --framework net5.0
Error: Invalid option(s):
--framework net5.0
'net5.0' is not a valid value for --framework. The possible values are:
net6.0 - Target net6.0
dotnet new --install net5.0
Warning: net5.0 is not found in NuGet feeds https://api.nuget.org/v3/index.json.
net5.0 could not be installed, the package does not exist.
#if (csharpFeature_TopLevelProgram)
// See https://aka.ms/new-console-template for more information
#endif
#if (!csharpFeature_ImplicitUsings)
using System;
#endif
#if (csharpFeature_TopLevelProgram)
Console.WriteLine("Hello, World!");
#else
namespace Company.ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
#endif
[pfemidi@pfemidi ~]$ dnf search dotnet
Last metadata expiration check: 20:14:19 ago on Sun 25 Sep 2022 10:50:05 PM MSK.
=================================== Name Exactly Matched: dotnet ===================================
dotnet.x86_64 : .NET CLI tools and runtime
======================================= Name Matched: dotnet =======================================
dotnet-apphost-pack-3.1.x86_64 : Targeting Pack for Microsoft.NETCore.App 3.1
dotnet-apphost-pack-6.0.x86_64 : Targeting Pack for Microsoft.NETCore.App 6.0
dotnet-build-reference-packages.x86_64 : Reference packages needed by the .NET Core SDK build
dotnet-host.x86_64 : .NET command line launcher
dotnet-hostfxr-3.1.x86_64 : .NET Core command line host resolver
dotnet-hostfxr-6.0.x86_64 : .NET command line host resolver
dotnet-runtime-3.1.x86_64 : NET Core 3.1 runtime
dotnet-runtime-6.0.x86_64 : NET 6.0 runtime
dotnet-sdk-3.1.x86_64 : .NET Core 3.1 Software Development Kit
dotnet-sdk-3.1-source-built-artifacts.x86_64 : Internal package for building .NET Core 3.1 Software
: Development Kit
dotnet-sdk-6.0.x86_64 : .NET 6.0 Software Development Kit
dotnet-sdk-6.0-source-built-artifacts.x86_64 : Internal package for building .NET 6.0 Software
: Development Kit
dotnet-targeting-pack-3.1.x86_64 : Targeting Pack for Microsoft.NETCore.App 3.1
dotnet-targeting-pack-6.0.x86_64 : Targeting Pack for Microsoft.NETCore.App 6.0
dotnet-templates-3.1.x86_64 : .NET Core 3.1 templates
dotnet-templates-6.0.x86_64 : .NET 6.0 templates
[pfemidi@pfemidi ~]$
❯ dotnet new console --help
Console App (C#)
Author: Microsoft
Description: A project for creating a command-line application that can run on .NET on Windows, Linux and macOS
Usage:
dotnet new console [options] [template options]
Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output
directory is used.
in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.
Template options:
-f, --framework <net7.0|net6.0|...> The target framework for the project.
Type: choice
net7.0 Target net7.0
net6.0 Target net6.0
net5.0 Target net5.0
netcoreapp3.1 Target netcoreapp3.1
Default: net7.0
--langVersion <langVersion> Sets the LangVersion property in the created project file
Type: text
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
--use-program-main Whether to generate an explicit Program class and Main method instead of
top-level statements.
Type: bool
Default: false
[pfemidi@pfemidi ~]$ dotnet new
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 webapp,razor [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
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
[pfemidi@pfemidi ~]$
[pfemidi@pfemidi ~]$ dotnet new --list
These templates matched your input:
Template Name Short Name Language Tags
------------------------------------------- -------------- ---------- --------------------------
ASP.NET Core Empty web [C#],F# Web/Empty
ASP.NET Core gRPC Service grpc [C#] Web/gRPC
ASP.NET Core Web API webapi [C#],F# Web/WebAPI
ASP.NET Core Web App webapp,razor [C#] Web/MVC/Razor Pages
ASP.NET Core Web App (Model-View-Control... mvc [C#],F# Web/MVC
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
Blazor Server App blazorserver [C#] Web/Blazor
Blazor WebAssembly App blazorwasm [C#] Web/Blazor/WebAssembly/PWA
Class Library classlib [C#],F#,VB Common/Library
Console App console [C#],F#,VB Common/Console
dotnet gitignore file gitignore Config
Dotnet local tool manifest file tool-manifest Config
EditorConfig file editorconfig Config
global.json file globaljson Config
MSTest Test Project mstest [C#],F#,VB Test/MSTest
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
NuGet Config nugetconfig Config
NUnit 3 Test Item nunit-test [C#],F#,VB Test/NUnit
NUnit 3 Test Project nunit [C#],F#,VB Test/NUnit
Protocol Buffer File proto Web/gRPC
Razor Class Library razorclasslib [C#] Web/Razor/Library
Razor Component razorcomponent [C#] Web/ASP.NET
Razor Page page [C#] Web/ASP.NET
Solution File sln Solution
Web Config webconfig Config
Worker Service worker [C#],F# Common/Worker/Web
xUnit Test Project xunit [C#],F#,VB Test/xUnit
[pfemidi@pfemidi ~]$
[pfemidi@pfemidi ~]$ dnf list --installed | grep dotnet
dotnet.x86_64 6.0.108-1.fc36 @updates
dotnet-apphost-pack-6.0.x86_64 6.0.8-1.fc36 @updates
dotnet-host.x86_64 6.0.8-1.fc36 @updates
dotnet-hostfxr-6.0.x86_64 6.0.8-1.fc36 @updates
dotnet-runtime-6.0.x86_64 6.0.8-1.fc36 @updates
dotnet-sdk-6.0.x86_64 6.0.108-1.fc36 @updates
dotnet-targeting-pack-6.0.x86_64 6.0.8-1.fc36 @updates
dotnet-templates-6.0.x86_64 6.0.108-1.fc36 @updates
[pfemidi@pfemidi ~]$
Я понял. У вас на скришоте dotnet 6.0.401, а у меня 6.0.108Вряд ли это имеет значение. Видимо для Fedora .Net просто какой-то не обрезанный...
и более позднего в официальном репозитории Microsoft для Linux нет.Для Fedora 36 есть - https://packages.microsoft.com/fedora/36/prod/
Совсем не ради одного. И в одном файле я всё не пишу.
и более позднего в официальном репозитории Microsoft для Linux нет.
Для Fedora 36 есть - https://packages.microsoft.com/fedora/36/prod/
Нужно добавить Майкрософтовский репозиторий и все ставить через тот же dnf.