Disabling a specific compiler warning in VS Code

I was able to get this to work. My solution looks something like this:

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
    <NoWarn>0169;8019</NoWarn>
</PropertyGroup>

<NoWarn> is PascalCase rather than camelCase, and the element is nested inside of a <PropertyGroup>.


Thanks to some code posted by user rakkarage on the Unity forums I was finally able to fix this by creating the following editor script in my Unity project:

using System.IO;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEditor;

[InitializeOnLoad]
class FixCSProjs : AssetPostprocessor
{
    private static void OnGeneratedCSProjectFiles() {
        Debug.Log("Fixing csproj files...");
        var dir = Directory.GetCurrentDirectory();
        var files = Directory.GetFiles(dir, "*.csproj");
        
        foreach (var file in files) {
            FixProject(file);
        }
    }
    
    static bool FixProject(string file) {
        var text = File.ReadAllText(file);
        var find = "<NoWarn>([0-9;]+)<\\/NoWarn>";
        var replace = "<NoWarn>$1;3003;3009</NoWarn>";
        
        if (Regex.IsMatch(text, find)) {
            text = Regex.Replace(text, find, replace);
            File.WriteAllText(file, text);
            return true;
            
        } else {
            return false;
        }
    }
}

That will add extra warning codes to the NoWarn attribute of each csproj file every time they're automatically generated by Unity. This has the important advantage that it does not involve manually editing files automatically generated by Unity, meaning it's more robust and is appropriate to include in a code repository such as git.

In my case I'm disabling warnings 3003 and 3009 (the CLS-compliance warnings) but just replace 3003;3009 in my code with whatever semicolon-separated warning codes you want and it should do the trick.

I'd also like to say that this is a heinous solution and I really wish there was a better, cleaner way of accomplishing this.

edit: This solution no longer works in the latest versions of Unity, as it no longer calls OnGeneratedCSProjectFiles().