-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish with async Main - Error CS8107: Feature 'async main' is not available in C# 7.0 #2751
Comments
@tonysneed can you show what your CSPROJ looks like? And also, after you publish your app, it's already been compiled, so where is the new compilation error coming from? A deployed app should just be DLL files, no CS files anymore. |
I had that happen to me recently on my Linux build machine. The reason was that I had only SDK 2.0 installed and the fix was adding 2.1 as well. |
Here is the csproj file for my ASPNETCORE Web Api: <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PlexClaims.Abstractions\PlexClaims.Abstractions.csproj" />
<ProjectReference Include="..\PlexClaims.ActiveDirectory\PlexClaims.ActiveDirectory.csproj" />
<ProjectReference Include="..\PlexClaims.Data\PlexClaims.Data.csproj" />
<ProjectReference Include="..\PlexClaims.Entities\PlexClaims.Entities.csproj" />
</ItemGroup>
</Project> Notice that Here is the Publish Profile I'm using: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>73d94c7c-d1a9-43f1-a12d-1e5abd08915d</ProjectGuid>
<publishUrl>bin\Release\PublishOutput</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project> |
@tonysneed thanks for sharing those. Do you have more info about what is happening when the error shows up? Once the app is published, there's no |
@Eilon Yes, the error takes place when the Publish command is building the project. Because the build step of Publish fails, the web app is never published. |
Oh I see, it's the publish process itself, not the published app. @vijayrkn - any idea why the publish process would use different C# settings than a regular build? |
@tonysneed I wonder if a different At least for debugging purposes, can you try moving the |
@Eilon - Don't know why this is happening. I will take a look. |
@tonysneed Did publish succeed after moving the LangVersion property to the main PropertyGroup? |
I'll try that. Need a bit of time. |
@vijayrkn Moving |
Looks like an issue with the handling of the platform name in publish. As a work-around you can either move the property outside or add these additional conditions.
|
@vijayrkn should this bug go to https://github.com/aspnet/websdk ? |
This is a bug in the VS side. VS bugs are tracked in developer community. Found another bug in the developer community for the same issue. This bug can be closed as dupe and we can use the developer community bug to track the issue progress. |
Thanks @vijayrkn ! |
I got the same error during build time. I used the .NET Core CLI. Adding the LangVersion to the main PropertyGroup fixed the issue for me. |
I got the same error building via Azure DevOps; When I checked the project file, it didn't have the LangVersion property at all, although VS Designer show that the default(latest) is selected. Issue got resolved after manually setting the value to Latest. |
When I publish an ASP.NET Core Web API that has an async Main method:
public static async Task Main
, I get the following error:This occurs even after setting the language version of each project in the solution to C# 7.2 for both Debug and Release build configurations.
Visual Studio 2017 Version: 15.5.2
OS Version: Windows 10 Pro Version 1709
The text was updated successfully, but these errors were encountered: