Adding onto adsamcik's answer, here's how you can exclude an entire project (like an integration tests project) programmatically:
via .NET Core's csproj file:
// xunit
<ItemGroup>
<AssemblyAttribute Include="Xunit.AssemblyTrait">
<_Parameter1>Category</_Parameter1>
<_Parameter2>SkipWhenLiveUnitTesting</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
// nunit
<ItemGroup>
<AssemblyAttribute Include="Nunit.Category">
<_Parameter1>SkipWhenLiveUnitTesting</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
// mstest
<ItemGroup>
<AssemblyAttribute Include="MSTest.TestCategory">
<_Parameter1>SkipWhenLiveUnitTesting</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
or via assemblyinfo.cs:
// xunit
[assembly: AssemblyTrait("Category", "SkipWhenLiveUnitTesting")]
// nunit
[assembly: Category("SkipWhenLiveUnitTesting")]
// mstest
[assembly: TestCategory("SkipWhenLiveUnitTesting")]
I figured out how to add the assembly attribute in .net core's csproj file via this SO answer. The attributes came from MS's documentation.