Skip to content

Instantly share code, notes, and snippets.

@dtwk2
dtwk2 / gist:9f1dd8ee2d790a1692482883e272785f
Last active March 27, 2020 15:07
How to set the background for all usercontrols in app resources (white background: using dark mode)
<!--https://stackoverflow.com/questions/5183801/black-background-for-xaml-editor-->
<Application
...
xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=PresentationFramework">
...
<Application.Resources>
...
<Style TargetType="Control">
<Style.Triggers>
Best solution (to copy to .csproj file)
- Runs after packing
- RoboCopy needs space after path arg e.g "..\df sd " if path has spaces in it otherwise do not include space.
- /XO ignores newer files in source
- /NFL /NDL /NJH partially removes RoboCopy output
- Since RoboCopy had different exit codes than MSBuild and many don't indicate error; need last two lines
<Target Name="PostPack" AfterTargets="Pack">
<Exec Command="
set source=&quot;$(ProjectDir)$(OutDir).. &quot;&#xD;&#xA;
@dtwk2
dtwk2 / PrivateProjectReferences
Created March 23, 2020 11:31
How to use private project references in nuget package from https://github.com/NuGet/Home/issues/3891
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net47</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" PrivateAssets="all" />
<ProjectReference Include="..\ClassLibrary3\ClassLibrary3.csproj" Condition="'$(TargetFramework)' == 'net47'" PrivateAssets="all" />
@dtwk2
dtwk2 / UsbDetector
Last active November 15, 2021 16:26
#nullable enable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Management;
using System.Reactive.Linq;
using System.Reactive.Subjects;
/// <summary>