Skip to content

Commit

Permalink
Additional notes on possible bugs in NuGet and dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
arialdomartini committed Oct 4, 2019
1 parent 3245215 commit 486ade0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
19 changes: 19 additions & 0 deletions README.md
Expand Up @@ -114,3 +114,22 @@ Therefore, to enable the strict control on compatibility, the csproj should cont
but for some reasons I wasn't able to identify, the setting is just ignored.

This seems to affect other warning codes as well. See the bug report on GitHub [Cannot disable NuGet warnings with dotnet 2.0](https://github.com/NuGet/Home/issues/5769)


## Multiple compilations
Astonishingly, 2 consecutive compilations of the same project produces a different number of warnings:

![compilation1](pics/compile1.png)
![compilation2](pics/compile2.png)

Another strange behaviour is that the warnings `NU*` such as `NU1702` are just ignored by the settings:

```xml
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
```

A possible explaination is that those are NuGet warnings, differently from `CS*` warnings, which are build related: during the first build, `nuget restore` is invoked, which produces the first warning (ignored by `TreatWarningsAsErrors`, which is a MSBuild directive). During the second build, NuGet is not invoked anymore.

This would be in line with what described by @xlegalles in [this comment](https://github.com/NuGet/Home/issues/5769#issuecomment-323295261).

Finally, it seems that there are also other issues with multi-target projects (see the NuGet issue [Framework Conditioned warning properties are not respected for multi-targeting projects](https://github.com/NuGet/Home/issues/5712))
8 changes: 4 additions & 4 deletions src/Console-Core2/Class1.cs
Expand Up @@ -6,8 +6,8 @@ public class Class1
{
}

// class A
// {
// public virtual void Finalize() {} // CS0465
// }
class A
{
public virtual void Finalize() {} // CS0465
}
}
6 changes: 6 additions & 0 deletions src/Core2/Class1.cs
Expand Up @@ -5,4 +5,10 @@ namespace Core2
public class Class1
{
}

class A
{
public virtual void Finalize() {} // CS0465
}

}
23 changes: 12 additions & 11 deletions src/Core2/Core2.csproj
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<WarningsAsErrors>NU1701,NU1702</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Library472-old\Library472-old.csproj" />
<ProjectReference Include="..\Library472\Library472.csproj" />
<!-- <ProjectReference Include="..\Library472\Library472.csproj" />-->
</ItemGroup>
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<!-- <NoWarn>1701;1702;1705;NU1702;NU1603;NU1605</NoWarn>-->
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<WarningsAsErrors>NU1702;1702</WarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Library472-old\Library472-old.csproj"/>
<ProjectReference Include="..\Library472\Library472.csproj"/>
</ItemGroup>
</Project>

0 comments on commit 486ade0

Please sign in to comment.