LoginSignup
0
0

More than 3 years have passed since last update.

Azure DevOps Services の .NET Framework デスクアプリ向け小ネタ集

Last updated at Posted at 2019-10-15

(自分用の備忘録です😅)

Windows Server の ANSI 文字コードは UTF-8

ProcessStartInfo.RedirectStandardInput = true
process.StandardInput.BaseStream に生データを流すと UTF-8 のボムが付いてしまうという恐ろしい事象に遭遇💦

Process.Start をする前までに、
Console.InputEncoding = Encoding.GetEncoding("latin1"); など、ボムが付かないエンコードに変更することで回避。

または… ボムをエミットしない UTF8Encoding に差し替えるなど:

    if (Console.InputEncoding == Encoding.UTF8)
    {
        Console.InputEncoding = new UTF8Encoding(false);
    }

なぜ Console.InputEncoding なのかといいますと、ILSpy で System.dll を覘くとそうなっていたからです💦

    if (startInfo.RedirectStandardInput)
    {
        standardInput = new StreamWriter(new FileStream(parentHandle, FileAccess.Write, 4096, isAsync: false), Console.InputEncoding, 4096);
        standardInput.AutoFlush = true;
    }

ImageMagick をインストール

Chocolatey でインストール可能。
しかし imagemagick に依存関係で付いてくる vcredist2010 は、バージョン違いによりインストールに失敗する模様。
--ignore-dependencies で無視してしまう。

- task: CmdLine@2
  displayName: "Install: ImageMagick (Install) 7.0.8.68"
  inputs:
    script: |
      choco install imagemagick --version 7.0.8.68 --ignore-dependencies
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0