Ben Gardner
Ben Gardner

Reputation: 131

dotnet run from Command Prompt

I'm attempting to use a batch file to run C#.

dotnet run
exit

However, I get dotnet run repeatedly running as the command in Command Prompt. also, when I simply type dotnet run into Command Prompt, I get the same thing: dotnet run continually running.

When I run the same command from Git Bash, though, it works fine. Same with PowerShell. What's going on here?

Edit: I'm trying to run the project, as opposed to opening the IDE

Upvotes: 2

Views: 4757

Answers (3)

Compo
Compo

Reputation: 38709

Change the name of the batch file from dotnet.bat or dotnet.cmd to a name which isn't also the name of a command!

Alternatively, include the extension with the command, dotnet.ext so that the interpreter doesn't search through extensions in %PathExt% to try to resolve the missing extension.

Preferably do both!

Upvotes: 1

Ben Gardner
Ben Gardner

Reputation: 131

I got around the issue by running Powershell from Command Prompt and running dotnet run there

Upvotes: 1

Tom Hood
Tom Hood

Reputation: 537

Not sure if you're trying to start a specific project or just open an IDE, but with Windows CMD, you start processes like this START "program-name-here". Most people also like to hide the CMD terminal so they run this:

@echo off START program-name-here

So, as an example if I wanted to open a specific .txt with Notepad, I would do this:

@echo off
start notepad c:\test.txt

Upvotes: 0

Related Questions