我有一个我正在努力建立的项目.它使用的是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]
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
我正在建设
__CODE__
同样,这在VS中调试时都有效.为什么从ConsoleApplication项目模板中获取一个简单的.exe太尴尬了!
Sef*_*efe 41
你的问题在于......
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>7.1</LangVersion>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
...您指定在Debug配置中使用C#7.1.
然而,随着......
dotnet publish -c Release -r win10-x64 Agent.csproj
Run Code Online (Sandbox Code Playgroud)
...你在发布配置中编译.
您还需要在Release中设置C#7.1.您还可以完全删除条件,这将为任何配置设置语言版本.
| 归档时间: |
|
| 查看次数: |
6082 次 |
| 最近记录: |