C#/오류

You may only use the Microsoft .NET Core Debugger (vsdbg) withVisual Studio Code, Visual Studio or Visual Studio for Mac softwareto help you develop and test your applications.

IT성민 2021. 6. 22. 20:35

맥북을 쓰는데 C#이 컴파일이 안되서 찾아보았다.

 

이런게 뜬다.....

 

아래는 해결책 인것 같다.

https://wiki.archlinux.org/title/Visual_Studio_Code_(한국어)

근데 저 ./.vscode/launch.json은 vscode쓰는사람일때이고, 나처럼 맥북써서 visual studio mac을 쓰는사람은 어찌? 할까? 많이 해맸다. 근데 느낌상 exe파일이 디버그 폴더에 안만들어지는게 위에것때문에 그런거 같지는 않다.  찾고 찾고 보니

https://www.c-sharpcorner.com/article/how-to-create-exe-for-net-cor/ 

 

How To Create EXE For .Net Core Console Application

In this article, you will learn how to create an exe for .NET Core Console application.

www.c-sharpcorner.com

여기서 보니 버그가 아니라 자연스러운거라고 한다. 즉 bin/Debug/.net5.0/ (솔루션 이름.exe)이 생성이 안되는게 당연하다는것이다.

명령 프롬프트에 

dotnet run 솔루션이름.dll

dotnet run 솔류션이름.dll 을 처주면 실행된다 한다. 하지만 이는 exe 파일이 아니니깐 좀 그렇다. 애초에 난 exe파일이 필요하기 때문이다. 그리고 난 저렇게 쳤는데 안되서 이런게 떴다.

 

그래서 찾아보니 여기에 해답을 줬다. run 을 빼야한다는 내용이다. 

dotnet 솔루션이름.dll

https://stackoverflow.com/questions/44757645/net-core-cli-run-error

 

.NET core CLI -> run ERROR

I have a little bit of problem with dotnet core CLI. When I am in a project directory and type: dotnet restore dotnet publish It creates published version of my code. And it says that my projec...

stackoverflow.com

여튼 뭐 이렇게 해서해서 실행은 한다 쳐도 dll 파일을 그냥 실행해 버리는 것이기 때문에 메인메소드의 아규먼트값이 0인 상태로 들어가서 바로 솔류션을 실행해 버린다...........난 헬로월드 하나 치고싶었던건데말이다.

 

 

 

 

using System;
using static System.Console;

namespace Hello
{
    class MainApp
    {
        //프로그램 실행이 시작되는 곳
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("사용법 : Hello.exe <이름>");
                return;
            }

            WriteLine("Hello, {0}!", args[0]);
        }
    }
}

여튼 위 블로그에들어가보면 잘 나와있는데 아래와 같이 하면 exe파일이 만들어지고 고민 해결이다.

 

dotnet publish -c Debug -r win10-x64