Visual Studio 2010 で Cloud Service プロジェクトのビルドに失敗したときの対処法

Visual Studio 2010 で Windows Azure 向けアプリのサンプルを作り直していたら、Cloud Service プロジェクトのビルドで下記のエラーが出て失敗してしまった。

The OutputPath property is not set for project 'AzureSample.ccproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='BPC'. This error may also appear if some other project is trying to follow a project-to-project reference to this project, this project has been unloaded or is not included in the solution, and the referencing project does not build using the same or an equivalent Configuration or Platform. C:\Windows\Microsoft.NET\Framework\v4.0.30128\Microsoft.Common.targets 483 9 AzureSample

'BPC' というプラットフォームを指定した覚えはない。どういうことだろう?

調べたところ、システム環境変数*1に PLATFORM が定義されていたのが原因のようだ。MSBuild が利用する変数名 Platform と衝突してしまい、システム環境変数 PLATFORM の値 'BPC' が使用されてしまったというわけ。

変数名の衝突を解消、つまりシステム環境変数から PLATFORM を削除してやれば、ビルドに成功するようになる。ただ、この環境変数を使っているアプリが既にインストールされている場合、正常に動作しなくなるけど・・・。

試す場合は自己責任でお願いします。

*1:[システムのプロパティ]-[詳細設定]-[環境変数]で設定できるやつ