2017-09-07 2 views
9

빌드하려고하는 프로젝트가 있습니다. 그것은 C# 7.1 기능을 사용하고, 나는 비주얼 스튜디오를 통해 실행할 수 있지만 난 내가 오류를 얻을이 .exe를 얻을 게시 할 때C# 7.1 DotNet Core 2.0 Exe 빌드

Agent.cs(8,30): error CS8107: Feature 'async main' is not available in C# 7. 
Please use language version 7.1 or greater. [C:\Users\stuarts\Documents\Visual 
Studio 2017\Projects\Agent\Agent\Agent.csproj] 
CSC : error CS5001: Program does not contain a static 'Main' method suitable 
for an entry point [C:\Users\stuarts\Documents\Visual Studio 
2017\Projects\Agent\Agent\Agent.csproj] 

csproj :

<Project Sdk="Microsoft.NET.Sdk"> 

    <PropertyGroup> 
    <OutputType>WinExe</OutputType> 
    <TargetFramework>netcoreapp2.0</TargetFramework> 
    <IsPackable>false</IsPackable> 
    <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion> 
    <RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion> 
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier> 
    <ApplicationIcon /> 
    <StartupObject /> 
    </PropertyGroup> 

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> 
    <LangVersion>7.1</LangVersion> 
    </PropertyGroup> 

    <ItemGroup> 
    <PackageReference Include="RabbitMQ.Client" Version="5.0.1" /> 
    </ItemGroup> 

</Project> 

내가 짓고 있어요

dotnet publish -c Release -r win10-x64 Agent.csproj 다시

으로,이 모든 작품 VS.에서 디버깅 할 때 ConsoleApplication 프로젝트 템플릿에서 간단한 .exe를 너무 어색하게 만드는 이유는 무엇입니까?

답변

19

귀하의 문제는 절에서 ...

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> 
    <LangVersion>7.1</LangVersion> 
</PropertyGroup> 

... 당신이 디버그 구성에서 C# 7.1을 사용하도록 지정하는 것입니다.

그러나,와 ...

dotnet publish -c Release -r win10-x64 Agent.csproj 

... 당신은 릴리스 구성에서 컴파일합니다.

릴리스에서도 C# 7.1을 설정해야합니다. 또한 모든 구성에 대해 언어 버전을 설정하는 조건을 완전히 제거 할 수 있습니다.

+0

고맙습니다! – Stuart

+0

@ 스튜어트 : 저의 기쁨. – Sefe

+1

@Stuart Debug와 Release에 대해 별도로 설정해야하는 특별한 이유가 있습니까? 또한 모든 구성에 대한 첫 번째 'PropertyGroup' 섹션에서 설정할 수 있습니다. –

관련 문제