dotnet new classlibChange Class1.cs to:
c#
class C
{
async void M() {}
}
dotnet build
dotnet buildThe second dotnet build prints the CS1998 warning, just like the first one.
The second dotnet build does not print any warnings:
> dotnet build
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 87,92 ms for C:\code\tmp\hwapp\hwapp.csproj.
Class1.cs(3,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\code\tmp\hwapp\hwapp.csproj]
hwapp -> C:\code\tmp\hwapp\bin\Debug\netstandard2.0\hwapp.dll
Build succeeded.
Class1.cs(3,16): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\code\tmp\hwapp\hwapp.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.37
> dotnet build
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 81,94 ms for C:\code\tmp\hwapp\hwapp.csproj.
hwapp -> C:\code\tmp\hwapp\bin\Debug\netstandard2.0\hwapp.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.96
dotnet --info output:
.NET Command Line Tools (2.1.300-preview2-008251)
Product Information:
Version: 2.1.300-preview2-008251
Commit SHA-1 hash: 94fd3fd392
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview2-008251\
Microsoft .NET Core Shared Framework Host
Version : 2.1.0-preview2-26131-06
Build : b13a0d5c331f374afd35ded57b9a4b4ab128864c
@svick, this is because, the second time you run 'dotnet build', various up-to-date checks succeed and the target that produced the warning does not run.
@tannergooding Then maybe warnings from previous runs should be saved somewhere and if some target doesn't run because it's up to date, its old warnings are still printed?
@svick, that seems like a general MSBuild feature request (which would impact both Desktop and .NET Core), rather than something CLI should be doing.
If you feel the same, could you open a bug against https://github.com/Microsoft/MSBuild?
@tannergooding Done.
I think you want to use the --no-incremental option, i.e.:
dotnet build --no-incremental
This does, however, mean a full rebuild.
Most helpful comment
I think you want to use the
--no-incrementaloption, i.e.:This does, however, mean a full rebuild.