Reputation: 546
I have a solution with old style .csproj files. Target is .NET Framework 4.8. I'm using MSBuild 17.2.1.25201.
I started using .editorconfig to configure severity of warning messages, for example:
[*.cs]
# XXX 3.1.0.153 depends on YYY (>= 3.1.0) but YYY 3.1.0 was not found.
# An approximate best match of YYY 3.1.0.69 was resolved.
dotnet_diagnostic.NU1603.severity = none
It worked perfectly and the warning NU1603 is not showing again.
Afterwards, I migrated the projects to new Project SDK and now the settings from .editorconfig are not being respected anymore. For example, the warning NU1603 started showing again.
Is there something additional I should do or is this just some kind of problem with msbuild/compiler?
New *.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{XXXX...}</ProjectGuid>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>My.Module</AssemblyTitle>
<Product>My.Module</Product>
<OutputPath>bin\$(Configuration)\</OutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
I keep .editorconfig in the root solution directory, so the structure look like this:
.\
.\My.ModuleA
.\My.ModuleB
.\My.sln
.\.editorconfig
Update I found that only this specific NU1603 cannot be ignored. The other warnings are ignored correctly.
Upvotes: 0
Views: 384
Reputation: 5384
I found this issue on GitHub which looks pretty similar to what you're encountering.
But you have another option, as you can read in the Microsoft docs: add the NoWarn
element to your csproj
file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{XXXX...}</ProjectGuid>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>My.Module</AssemblyTitle>
<Product>My.Module</Product>
<OutputPath>bin\$(Configuration)\</OutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoWarn>NU1603</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
</Project>
And just for the sake of completeness: you can omit a couple of default elements within your csproj
. Since I see a lot of default values, it probably can look similar to this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoWarn>NU1603</NoWarn>
</PropertyGroup>
</Project>
Upvotes: 1