Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)

Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법

아래의 사이트에 방문하면,

dotnet/roslyn
; https://github.com/dotnet/roslyn

소스 코드와 함께 설치 방법이 나옵니다. 그렇다고 소스 코드를 직접 빌드할 필요가 없는데, 왜냐하면 빌드 버전을 이미 NuGet을 통해 공개하고 있기 때문입니다. 따라서 nuget을 이용해 현재의(2019-03-04 기준 C# 7.3) C# 컴파일러를 다음과 같이 다운로드할 수 있습니다.

# Install C# and VB compilers
c:\git_clone>nuget install Microsoft.Net.Compilers

그럼 하위에 "Microsoft.Net.Compilers.2.10.0" 폴더가 생기고 다음과 같이 C# 컴파일러가 지원하는 언어의 버전을 알아낼 수 있습니다.

c:\git_clone\Microsoft.Net.Compilers.2.10.0\tools>csc -langversion:?
Supported language versions:
default
1
2
3
4
5
6
7.0 (default)
7.1
7.2
7.3 (latest)
latest

물론 소스 코드 파일 기준으로 daily 빌드를 받는 것도 가능합니다. 이를 위해 우선 다음의 NuGet feed를 등록해야 합니다.

https://dotnet.myget.org/F/roslyn/api/v3/index.json

NuGet의 sources는 결국 "%AppData%\NuGet\NuGet.config" 파일에 있으므로 이것을 편집해도 되는데,

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <disabledPackageSources />
  <activePackageSource>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </activePackageSource>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageSources>
    <!--add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /-->
   <clear />
    <add key="AspNetVNext" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
    <add key="NetCoreVNext" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
  <packageManagement>
    <add key="format" value="1" />
    <add key="disabled" value="False" />
  </packageManagement>
  <apikeys>
    <add key="https://www.nuget.org/api/v2/package" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAoNzryzUGzUiymbsVqn4hCgAAAAACAAAAAAAQZgAAAAEAACAAAACOH/8oz9g6rvJfQAWT4F2W69+d0WEjD7FpgJy3ufhYcQAAAAAOgAAAAAIAACAAAABNmEBkzKhr/aPwmx6Fjr6cxCd8u0R9+kOwv66Sp08eXjAAAACyyKE5II1du9lJ0MmVlVWWiCWYZR/bbS1qh9In3uL6Jct+2D8kTNibrGnANGVBurhAAAAAR+4oRfAdRIh3E7MOpIkZURR/UIsT6uis3kgksspnEAGXiz5BM6VNsmdWQAIaZXhE6WDOXn2xazvp3zWp1OKZsw==" />
  </apikeys>
</configuration>

따라서 다음과 같이 rosyln 항목을 NuGet.org보다 위에 넣어줍니다.

<packageSources>
	<!--add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /-->
	<clear />
	<add key="AspNetVNext" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
	<add key="NetCoreVNext" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
	<add key="RoslynNext" value="https://dotnet.myget.org/F/roslyn/api/v3/index.json" />
	<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>

반영 여부를 확인해 주고,

E:\git_clone\cs8> nuget sources
Registered Sources:

  1.  AspNetVNext [Enabled]
      https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
  2.  NetCoreVNext [Enabled]
      https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
  3.  RoslynNext [Enabled]
      https://dotnet.myget.org/F/roslyn/api/v3/index.json
  4.  NuGet.org [Enabled]
      https://api.nuget.org/v3/index.json

이제 다음과 같이 실행해 주면 됩니다.

c:\git_clone> nuget install Microsoft.Net.Compilers -Version 3.1.0-beta1-19153-01

위에 기재한 이상한 버전 번호는 다음의 갤러리로 들어가 구할 수 있습니다.

roslyn - Microsoft.Net.Compilers
; https://dotnet.myget.org/feed/roslyn/package/nuget/Microsoft.Net.Compilers

참고로, NuGet.config에 별도 소스를 등록하고 싶지 않다면 다음과 같이 nuget 명령에 -Source를 지정해도 됩니다.

c:\git_clone> nuget install Microsoft.Net.Compilers -Version 3.1.0-beta1-19153-01 -Source https://dotnet.myget.org/F/roslyn/api/v3/index.json




자, 그럼 설치 폴더의 하위인 tools 폴더로 들어가,

c:\git_clone> cd c:\git_clone\Microsoft.Net.Compilers.3.1.0-beta1-19153-01\tools

다음과 같이 지원되는 C# 언어 버전을 확인할 수 있습니다.

c:\git_clone\Microsoft.Net.Compilers.3.1.0-beta1-19153-01\tools> csc -langversion:?
Supported language versions:
default
1
2
3
4
5
6
7.0
7.1
7.2
7.3 (default)
8.0 *beta*
latestmajor
preview
latest

그리고 C# 8.0의 신규 문법으로 작성한 프로그램을 빌드한다면 다음과 같이 langversion 옵션을 지정합니다.

E:\git_clone\cs8\sample\ConsoleApp1\ConsoleApp1> csc Program.cs -langversion:8




혹시나, 그래도 roslyn을 빌드하고 싶다면 (약간 옛날 글이지만) 아래의 글을 참고해 직접 빌드해도 됩니다. ^^

C# 6.0 오픈 소스 컴파일러 Roslyn - 빌드 및 테스트 방법
; https://www.sysnet.pe.kr/2/0/10812




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 3/5/2019]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [31]  32  33  34  35  36  37  38  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
12855정성태11/13/20216244개발 환경 구성: 605. Azure App Service - Kudu SSH 환경에서 FTP를 이용한 파일 전송
12854정성태11/13/20217798개발 환경 구성: 604. Azure - 윈도우 VM에서 FTP 여는 방법
12853정성태11/10/20216160오류 유형: 766. Azure App Service - JBoss 호스팅 생성 시 "This region has quota of 0 PremiumV3 instances for your subscription. Try selecting different region or SKU."
12851정성태11/1/20217550스크립트: 34. 파이썬 - MySQLdb 기본 예제 코드
12850정성태10/27/20218696오류 유형: 765. 우분투에서 pip install mysqlclient 실행 시 "OSError: mysql_config not found" 오류
12849정성태10/17/20217837스크립트: 33. JavaScript와 C#의 시간 변환 [1]
12848정성태10/17/20218811스크립트: 32. 파이썬 - sqlite3 기본 예제 코드 [1]
12847정성태10/14/20218657스크립트: 31. 파이썬 gunicorn - WORKER TIMEOUT 오류 발생
12846정성태10/7/20218414스크립트: 30. 파이썬 __debug__ 플래그 변수에 따른 코드 실행 제어
12845정성태10/6/20218241.NET Framework: 1120. C# - BufferBlock<T> 사용 예제 [5]파일 다운로드1
12844정성태10/3/20216246오류 유형: 764. MSI 설치 시 "... is accessible and not read-only." 오류 메시지
12843정성태10/3/20216692스크립트: 29. 파이썬 - fork 시 기존 클라이언트 소켓 및 스레드의 동작파일 다운로드1
12842정성태10/1/202125051오류 유형: 763. 파이썬 오류 - AttributeError: type object '...' has no attribute '...'
12841정성태10/1/20218519스크립트: 28. 모든 파이썬 프로세스에 올라오는 특별한 파일 - sitecustomize.py
12840정성태9/30/20218618.NET Framework: 1119. Entity Framework의 Join 사용 시 다중 칼럼에 대한 OR 조건 쿼리파일 다운로드1
12839정성태9/15/20219668.NET Framework: 1118. C# 11 - 제네릭 타입의 특성 적용파일 다운로드1
12838정성태9/13/20219317.NET Framework: 1117. C# - Task에 전달한 Action, Func 유형에 따라 달라지는 async/await 비동기 처리 [2]파일 다운로드1
12837정성태9/11/20218223VC++: 151. Golang - fmt.Errorf, errors.Is, errors.As 설명
12836정성태9/10/20217830Linux: 45. 리눅스 - 실행 중인 다른 프로그램의 출력을 확인하는 방법
12835정성태9/7/20219072.NET Framework: 1116. C# 10 - (15) CallerArgumentExpression 특성 추가 [2]파일 다운로드1
12834정성태9/7/20217467오류 유형: 762. Visual Studio 2019 Build Tools - 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
12833정성태9/6/20216910VC++: 150. Golang - TCP client/server echo 예제 코드파일 다운로드1
12832정성태9/6/20217773VC++: 149. Golang - 인터페이스 포인터가 의미 있을까요?
12831정성태9/6/20216301VC++: 148. Golang - 채널에 따른 다중 작업 처리파일 다운로드1
12830정성태9/6/20218568오류 유형: 761. Internet Explorer에서 파일 다운로드 시 "Your current security settings do not allow this file to be downloaded." 오류
12829정성태9/5/202110206.NET Framework: 1115. C# 10 - (14) 구조체 타입에 기본 생성자 정의 가능파일 다운로드1
... [31]  32  33  34  35  36  37  38  39  40  41  42  43  44  45  ...