简体   繁体   English

通过 DotNet CLI 创建以 .NET 框架为目标的新 ASP.NET 核心项目

[英]Create new ASP.NET Core project that targets .NET Framework by DotNet CLI

I try to create a new ASP.NET Core project that target the classic .NET Framework.我尝试创建一个针对经典 .NET 框架的新 ASP.NET 核心项目。 The template web and webapi have the option framework , but this don't accept .NET Framework value like:模板webwebapi具有选项framework ,但这不接受 .NET 框架值,例如:

dotnet new web --name MyWebProject --framework net48

Error: Invalid parameter(s):错误:无效参数:
--framework net48 --framework net48
'net48' is not a valid value for --framework (Framework). 'net48' 不是 --framework(框架)的有效值。

How create ASP.NET Core project that targets .NET Framework from DotNet CLI?如何从 DotNet CLI 创建针对 .NET 框架的 ASP.NET 核心项目?

If it isn't possible, do you know a solution to do this in command line?如果不可能,您知道在命令行中执行此操作的解决方案吗?

PS: I know the Visual Studio template ASP.NET Core empty let select .NET Framework. PS:我知道Visual Studio模板ASP.NET Core empty让select .NET框架。 I search a solution from command line, preferably with DotNet CLI.我从命令行搜索解决方案,最好使用 DotNet CLI。

I used this to create ASP.NET Core empty Web App that targets 4.7.1:我用它来创建针对 4.7.1 的 ASP.NET 核心空 Web 应用程序:

dotnet new web --target-framework-override net471

I saw it there .我在那里看到了。 The generated project file looks like this:生成的项目文件如下所示:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net471</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" />
  </ItemGroup>

</Project>

There is no option to set .net frameworks with a default template.没有使用默认模板设置 .net 框架的选项。 You can view the framework's options by running: dotnet new web --help :您可以通过运行查看框架的选项: dotnet new web --help

image图片

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用 dotnet new 创建一个 ASP.NET Web Application Empty .Net Framework 4.7.2 项目? - Is it possible to use dotnet new to create an ASP.NET Web Application Empty .Net Framework 4.7.2 project? 使用autofac在asp.net核心项目上创建新范围 - Create new scope on asp.net core project using autofac do.net 意外退出 - 在 ASP.NET Core 中创建新项目后 - dotnet quit unexpectedly - after creating new project in ASP.NET Core 为什么在通过 dotnet CLI 运行 ASP.NET Core 应用程序时看到项目目录名称而不是 dotnet(进程外)? - Why do I see project directory name instead of dotnet(out-of-process) while running ASP.NET Core app through dotnet CLI? 引用ASP.NET Core中的现有.NET Framework项目 - reference an existing .NET Framework Project in an ASP.NET Core Asp.net核心 - 找不到dotnet测试 - Asp.net core - dotnet test not found 在针对完整.NET Framework的asp.net Core应用上使用SignalR - Using SignalR on an asp.net Core app that targets the full .NET Framework 我可以使用Microsoft Dotnet CLI构建ASP.NET Core Web应用程序吗? - Can I build ASP.NET Core web application using Microsoft Dotnet CLI? 创建项目 ASP.NET Core (.NET Core) 和 ASP.NET Core (.NET Framework) 有什么区别 - What is the difference between creating a project ASP.NET Core (.NET Core) and ASP.NET Core (.NET Framework) 如何在ASP.NET Core项目中设置实体框架 - How to setup Entity Framework in ASP.NET Core project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM