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

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11839정성태3/12/201913988디버깅 기술: 124. .NET Core 웹 앱을 호스팅하는 Azure App Services의 프로세스 메모리 덤프 및 windbg 분석 개요 [3]
11838정성태3/7/201916761.NET Framework: 811. (번역글) .NET Internals Cookbook Part 1 - Exceptions, filters and corrupted processes [1]파일 다운로드1
11837정성태3/6/201926377기타: 74. 도서: 시작하세요! C# 7.3 프로그래밍 [10]
11836정성태3/5/201914329오류 유형: 525. Visual Studio 2019 Preview 4/RC - C# 8.0 Missing compiler required member 'System.Range..ctor' [1]
11835정성태3/5/201914071.NET Framework: 810. C# 8.0의 Index/Range 연산자를 .NET Framework에서 사용하는 방법 및 비동기 스트림의 컴파일 방법 [3]파일 다운로드1
11834정성태3/4/201912976개발 환경 구성: 432. Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법
11833정성태3/4/201913728개발 환경 구성: 431. Visual Studio 2019 - CMake를 이용한 공유/실행(so/out) 리눅스 프로젝트 설정파일 다운로드1
11832정성태3/4/201910771오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201910325오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201910165오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201912058개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201918449개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201912378오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201912267오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201917121개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201911919오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201913383오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201911539오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201912010오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201915124오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201913796Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201912712VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/20199907오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201912383Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201911289오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201910089오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
... 61  62  63  64  65  66  67  68  69  70  71  [72]  73  74  75  ...