3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VS2022 Setupプロジェクトにおけるエラーとその対処方法(3つの必要条件)

Last updated at Posted at 2025-03-23

いいね・ストックで追記。とにかくいいねの方向で

WPFアプリケーションにおけるインストーラ制作において、Microsoft Visual Studio Installer Projects 2022を導入すると、フリーソフトによくあるインストーラを出力させることができます。

本稿では以下の記事を参考に、そのエラーとトラブルシューティングを提示する記事です。
可能な限りシンプルに行きましょう。

詳しい解説記事

ハイレッツゴ。

必要条件1

・SetUpプロジェクト内の親プロパティ内で、Target FramewWorkとTarget Runtime ターゲットランタイムがセットアッププロジェクト内の項目の公開とのものと一致している

※後で判明したのだが「発行」側の設定は変えても問題なかった
image.png

証明:試しに変更してビルドしてみる

とりあえず手っ取り早くSetUpプロジェクトのほうをソリューションのプロパティから変更する

image.png

→ X86に変更する(発行の設定と不一致)

以下出力結果

編集リクはノーサンキューで
23:11 でビルドが開始されました...
------ Starting pre-build validation for project 'HaruaConvert_Setup' ------ 
------ Pre-build validation for project 'HaruaConvert_Setup' completed ------
1>------ ビルド開始: プロジェクト: HaruaConvert_Setup, 構成: Release ------
Building file 'C:\git\HaruaConvert\HaruaConvert_Setup\Release\HaruaConvert_Setup.msi'...
WARNING: Configuration file 'C:\git\HaruaConvert\WpfApp3\obj\x64\Release\net8.0-windows10.0.22621.0\HaruaConvert.dll.config' is being used to configure all executables
WARNING: File 'HaruaConvert.exe' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'x64' is not compatible with the project's target platform 'x86'
ERROR: File 'HaruaConvert.dll' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'AMD64' is not compatible with the project's target platform 'x86'
WARNING: File 'HaruaConvert.dll' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'x64' is not compatible with the project's target platform 'x86'
WARNING: File 'HaruaConvert.exe' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'x64' is not compatible with the project's target platform 'x86'
ERROR: File 'HaruaConvert.dll' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'AMD64' is not compatible with the project's target platform 'x86'
WARNING: File 'HaruaConvert.dll' of project output '項目の公開 from HaruaConvert (Release x64)' targeting 'x64' is not compatible with the project's target platform 'x86'
Build process cancelled
========== ビルド: 成功 0、失敗 1、最新の状態 1、スキップ 0 ==========
=========== ビルド は 23:11 で完了し、02.566 秒 掛かりました ==========

ビルドは失敗している。

→もとに戻してみる

ビルドに成功。

部分的に抜粋
Packaging file 'NAudio.Midi.dll'...
========== ビルド: 成功 1、失敗 0、最新の状態 1、スキップ 0 ==========
=========== ビルド は 23:14 で完了し、15.991  掛かりました ==========

シンプルですね。

必要条件2

User's Desktop

において、AlwaysCreateプロパティがTrueでなければならない。

ハイレッツゴ。

User’s DeskTop

image.png

なんか即失敗した

再編集なし
========== ビルド: 成功 0、失敗 1、最新の状態 1、スキップ 0 ==========
=========== ビルド は 23:34 で完了し、00.204  掛かりました ==========

User's Program Menuは?

image.png

前回のUser’s DesktopはTrueに戻す

→ 普通に成功
※動作するかはまだ調べてません
 →念のためソリューションのクリーン
 → 問題なく成功。(ちなみにクリーンを挟むと成功 2 と出る)

Application Folder は?

image.png

→Falseに変更する

 → ***ビルド成功***
   → ソリューションのクリーン
      → ビルド成功

※動作するかはまだ調べてません
いいね・ストックで追記。

必要条件3

プロジェクト出力項目の公開のランタイム設定が統一されていないと失敗する

おそらく、他の項目の公開と一致してないといけないと考えてる
 →出力対象プロジェクトの「発行」設定は適当に変えてもビルド成功だったため。多分その辺は独立している。アプリが動作するかどうかは別

試しにRelease Any CPUとしてみる
Application Folder直下で試す

image.png

ハイレッツゴ。

再編集不可
0:05 でビルドが開始されました...
------ Starting pre-build validation for project 'HaruaConvert_Setup' ------ 
------ Pre-build validation for project 'HaruaConvert_Setup' completed ------
1>------ ビルド開始: プロジェクト: HaruaConvert_Setup, 構成: Debug ------
Building file 'C:\git\HaruaConvert\HaruaConvert_Setup\Debug\HaruaConvert_Setup.msi'...
ERROR: Unrecoverable build error - 0x80004003
========== ビルド: 成功 0、失敗 1、最新の状態 1、スキップ 0 ==========
=========== ビルド は 0:05 で完了し、01.899 秒 掛かりました ==========

即失敗でした。

その他わかったこと

プロジェクト出力グループは複数あってもよい

image.png

適当に追加しても成功。
どの場所に追加してもよい。後々困るのかどうかは知らないが
ただしTarget Runtime等は一致させること

プロジェクト出力グループを適当な場所に追加

image.png

ターゲットランタイムは合わせないと失敗する、これは既知なので合わせる。

問題なく成功。

image.png

「発行」するアプリケーションの設定は適当でもいい

(かなりたぶん)設定上は独立しているのでアプリが動作するかどうかに関係なく出力はされる。

x86とかに変える

image.png

ここを再編集してターゲットランタイムを変えたりしてみる
→新しいプロファイルが、SetUpプロジェクトで読み込んでいるものと一致しないため失敗。

改めてハイレッツゴ

→ビルド成功。

他の設定もいじってみたけど一応出力はされた。

あとがき

アプリが動作するかどうかの知見はあくまで「発行(Publisher)」の設定に依存するようです。SetUpプロジェクト側はビルドに成功するかどうからしい。

面白くなかったらBadボタン、チャンネル登録をお願いします。
可愛いひつじ様お待ちしてます(他は要らんので)。

あ、それとネタバレゲーム動画嫌いだったらごめんなさい(陳謝)

3
2
1

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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?