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

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  [11]  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13357정성태5/16/20233575.NET Framework: 2124. C# - Semantic Kernel의 Planner 사용 예제파일 다운로드1
13356정성태5/15/20233899DDK: 10. Device Driver 테스트 설치 관련 오류 (Code 37, Code 31) 및 인증서 관련 정리
13355정성태5/12/20233836.NET Framework: 2123. C# - Semantic Kernel의 ChatGPT 대화 구현 [1]파일 다운로드1
13354정성태5/12/20234094.NET Framework: 2122. C# - "Use Unicode UTF-8 for worldwide language support" 설정을 한 경우, 한글 입력이 '\0' 문자로 처리
13352정성태5/12/20233704.NET Framework: 2121. C# - Semantic Kernel의 대화 문맥 유지파일 다운로드1
13351정성태5/11/20234209VS.NET IDE: 185. Visual Studio - 원격 Docker container 내에 실행 중인 응용 프로그램에 대한 디버깅 [1]
13350정성태5/11/20233480오류 유형: 859. Windows Date and Time - Unable to continue. You do not have permission to perform this task
13349정성태5/11/20233791.NET Framework: 2120. C# - Semantic Kernel의 Skill과 Function 사용 예제파일 다운로드1
13348정성태5/10/20233689.NET Framework: 2119. C# - Semantic Kernel의 "Basic Loading of the Kernel" 예제
13347정성태5/10/20234082.NET Framework: 2118. C# - Semantic Kernel의 Prompt chaining 예제파일 다운로드1
13346정성태5/10/20233911오류 유형: 858. RDP 원격 환경과 로컬 PC 간의 Ctrl+C, Ctrl+V 복사가 안 되는 문제
13345정성태5/9/20235313.NET Framework: 2117. C# - (OpenAI 기반의) Microsoft Semantic Kernel을 이용한 자연어 처리 [1]파일 다운로드1
13344정성태5/9/20236491.NET Framework: 2116. C# - OpenAI API 사용 - 지원 모델 목록 [1]파일 다운로드1
13343정성태5/9/20234365디버깅 기술: 192. Windbg - Hyper-V VM으로 이더넷 원격 디버깅 연결하는 방법
13342정성태5/8/20234273.NET Framework: 2115. System.Text.Json의 역직렬화 시 필드/속성 주의
13341정성태5/8/20234007닷넷: 2114. C# 12 - 모든 형식의 별칭(Using aliases for any type)
13340정성태5/8/20234080오류 유형: 857. Microsoft.Data.SqlClient.SqlException - 0x80131904
13339정성태5/6/20234746닷넷: 2113. C# 12 - 기본 생성자(Primary Constructors)
13338정성태5/6/20234265닷넷: 2112. C# 12 - 기본 람다 매개 변수파일 다운로드1
13337정성태5/5/20234769Linux: 59. dockerfile - docker exec로 container에 접속 시 자동으로 실행되는 코드 적용
13336정성태5/4/20234576.NET Framework: 2111. C# - 바이너리 출력 디렉터리와 연관된 csproj 설정
13335정성태4/30/20234677.NET Framework: 2110. C# - FFmpeg.AutoGen 라이브러리를 이용한 기본 프로젝트 구성 - Windows Forms파일 다운로드1
13334정성태4/29/20234312Windows: 250. Win32 C/C++ - Modal 메시지 루프 내에서 SetWindowsHookEx를 이용한 Thread 메시지 처리 방법
13333정성태4/28/20233754Windows: 249. Win32 C/C++ - 대화창 템플릿을 런타임에 코딩해서 사용파일 다운로드1
13332정성태4/27/20233855Windows: 248. Win32 C/C++ - 대화창을 위한 메시지 루프 사용자 정의파일 다운로드1
13331정성태4/27/20233885오류 유형: 856. dockerfile - 구 버전의 .NET Core 이미지 사용 시 apt update 오류
1  2  3  4  5  6  7  8  9  10  [11]  12  13  14  15  ...