简体   繁体   English

如何使用别名从命令行运行 dotnet 控制台应用程序

[英]How to run a dotnet console app from the command line using an alias

I know how to do this with batch files, you add the path to the system variable but I cannot seem to find the answer to my question anywhere.我知道如何使用批处理文件执行此操作,您将路径添加到系统变量,但我似乎无法在任何地方找到我的问题的答案。 Anyone knows?有谁知道?

example: Instead of navigating to the app directory and running dotnet run I would like to just call a command like myApp from any directory I'm in.示例:我不想导航到 app 目录并运行dotnet run我只想从我所在的任何目录调用myApp之类的命令。

PS: Im using windows 10. PS:我使用的是 windows 10。

you can just use a shell alias if you work on cmd如果您在 cmd 上工作,您可以只使用 shell 别名

doskey runMyApp=dotnet run path\to\my\app

more info given here 此处提供更多信息

First, you need to know which folders are in your path environment variable.首先,您需要知道路径环境变量中有哪些文件夹。 You can see those if you go to ControlPanel/System/Advanced settings/Environment Variables如果您将 go 到 ControlPanel/System/Advanced settings/Environment Variables,您可以看到这些

So, you either use one of the existing folders, or you add a new folder.因此,您要么使用现有文件夹之一,要么添加一个新文件夹。

After that, you can can compile your dotnet core program to a.exe file.之后,您可以将您的 dotnet 核心程序编译为 .exe 文件。 See this answer for details on how to do that.有关如何执行此操作的详细信息, 请参阅此答案

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

相关问题 使用 dotnet run 时如何调试 .NET 核心控制台应用程序 - How to Debug a .NET Core Console App When Using dotnet run 如何使用dotnet在命令行中传递参数? - How to pass arguments in command line using dotnet? 如何使用使用命令行选项的 dotnet 应用程序运行 VSCode 调试器? - How do run VSCode debugger with a dotnet app that uses command line options? .NET Core 控制台应用程序与 EF Core 使用 dotnet run 命令运行时无法正常工作,引发身份验证失败异常 - .NET Core console application with EF Core is not working when run from using dotnet run command, throwing authentication failed exception 如何使用 do.net 测试命令行运行单个 xunit C# 测试 - How to run a single xunit C# test using dotnet test command line 如何针对dotnet核心控制台应用程序运行验收测试? - How to run acceptance test against dotnet core console app? 如何从 dotnet 命令行在 macOS 上安装和运行 MDbg? - How can I install and run MDbg on macOS from the dotnet command line? 从命令提示符运行dotnet - dotnet run from Command Prompt 如何通过 docker 运行将命令行 Arguments 传递到 .NET 控制台应用程序(Docker for Windows) - How to pass Command Line Arguments to .NET Console App through docker run (Docker for Windows) 在测试中在后台运行dotnet控制台 - Run dotnet console in background from test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM