dotnet

async/await in dotnet

certificate validation overriding

ServicePointManager.ServerCertificateValidationCallback += 
  new RemoteCertificateValidationCallback(ValidateCertificate);

public static bool ValidateCertificate(object sender, X509Certificate cert, 
  X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
      return true;
}

persistkeyset

Installed certificates expiring? Use X509KeyStorageFlags.PersistKeySet - What is the impact of PersistKeySet

xml transforms in non-web projects using msbuild

Adding XML transforms to non-Web projects (Console, Winforms, WPF etc.)

  1. Add Debug/Release versions of confit as XDT transforms
  2. Add MSBuild.Microsoft.VisualStudio.Web.targets nuget PackageReference
  3. Import targets (conditionally or it won’t load the first time)
  4. Add TransformXml to AfterBuild
<Project>
    ...
      <ItemGroup>
        <None Include="App.config" />
        <None Include="App.Debug.config">
            <DependentUpon>App.config</DependentUpon>
            <SubType>Designer</SubType>
        </None>
        <None Include="App.Release.config">
            <DependentUpon>App.config</DependentUpon>
            <SubType>Designer</SubType>
        </None>
    </ItemGroup>
    ...
    <ItemGroup>
        <PackageReference Include="MSBuild.Microsoft.VisualStudio.Web.targets">
            <Version>14.0.0.3</Version>
        </PackageReference>
    </ItemGroup>
    ...
    <Import Condition="Exists('$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets')" Project="$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets" />
    ...
    <Target Name="AfterBuild">
        <TransformXml Source="@(AppConfigWithTargetPath)" Transform="App.$(Configuration).config" Destination="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')" />
    </Target>
</Project>

csharp versions

C# Versions