我有一个项目正在尝试构建。它使用C# 7.1功能,我可以通过Visual Studio运行它,但是当我尝试发布以获取.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
再次强调,这在Visual Studio中进行调试时都是起作用的。为什么从控制台应用程序项目模板中获取一个简单的.exe文件这么麻烦!