LoginSignup
0
0

VS2017のツールウィンドウ拡張を作る(vsix)

Posted at

自分用の拡張機能を諸事情あってVS2017で作りたかった。
少し手間取ったところの自分用まとめ過不足がありそうな気しかしない。
なにかあったら適宜更新

SDKをインストール

https://learn.microsoft.com/ja-jp/previous-versions/visualstudio/visual-studio-2017/extensibility/installing-the-visual-studio-sdk?view=vs-2017#install-the-visual-studio-sdk-after-installing-visual-studio
書いてあるとおり

プロジェクトを作成

  1. プロジェクトテンプレートの検索で「vsix」で検索
  2. vsixのC#を選択
  3. 適当に名前を付けて作成
  4. プロジェクトを右クリック→追加→新しい項目
  5. VisualC#アイテム→Extensibility→Custom Tool Window
    image.png
  6. とりあえず一旦ビルド
  7. 変なエラーが出る。
エラー		"VSCTCompiler" タスクが予期せずに失敗しました。
System.OutOfMemoryException: メモリが不足しています。
   場所 System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
   場所 Microsoft.VisualStudio.CommandTable.BitmapItem.Read(TextReadVSCTCStream s, XmlElement itemNode)
   場所 Microsoft.VisualStudio.CommandTable.ItemList.Read(TextReadVSCTCStream s, XmlElement listNode)
   場所 Microsoft.VisualStudio.CommandTable.CommandTable.ReadCMDSSection(TextReadVSCTCStream s, XmlElement listNode)
   場所 Microsoft.VisualStudio.CommandTable.CommandTable.Read(TextReadVSCTCStream s)
   場所 Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, ReadOptions ro, IMessageProcessor errorProcessor)
   場所 Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, IMessageProcessor errorProcessor)
   場所 Microsoft.VisualStudio.CommandTable.Compiler.Compile()
   場所 Microsoft.VisualStudio.CommandTable.VSCTCompiler.Execute()	VSIXProject1			

<プロジェクト>\Resources\ToolWindow1Command.png
を適当なpngファイルに置き換えればOK
https://tech.surviveplus.net/archives/1190

ツールバーに表示

書いてあるとおりにやれば大丈夫だった。
とりあえずツールバーに追加するだけなら↓までやればOK
https://learn.microsoft.com/ja-jp/previous-versions/visualstudio/visual-studio-2017/extensibility/adding-a-tool-window?view=vs-2017#add-a-toolbar-to-the-tool-window

作った拡張機能のインストール

\bin\Releaseにあるvsixファイルをダブルクリック

拡張機能の更新

  1. source.extension.vsixmanifestをダブルクリックして開く
  2. Versionを更新
  3. VS2017を閉じる
  4. \bin\Releaseにあるvsixファイルをダブルクリック

メモ

  • XAMALでStackPanelにVerticalAlignment="Stretch"を追加しているのにサイズが固定のまま!なぜ!
     →デフォルトで置いてあるUserControlの方にVerticalAlignment="Stretch"を付けないといけなかった
    これ必要なんだろうか…?後で確認する
  • Styleにデフォルト値的なものを設定したい
     →XAMAL内内でStyleタグのx:Key=を外してTargetTypeだけ残せばOK
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