9

Azure Web サイトへの Bitbucket デプロイをセットアップしようとしています。Bitbucket と Azure を正常にリンクしましたが、Bitbucket にプッシュすると、Azure サイトで次のエラーが表示されます。

ここに画像の説明を入力

[ログの表示] をクリックすると、次のコンパイル エラーが表示されます。

    D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "WebMatrix.WebData, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(5,7): error CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(9,38): error CS0246: The type or namespace name 'ExtendedMembershipProvider' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(3,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    CustomMembershipProvider.cs(198,37): error CS0246: The type or namespace name 'OAuthAccountData' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(40,10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(40,10): error CS0246: The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(73,10): error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]
    Models\AccountModels.cs(73,10): error CS0246: The type or namespace name 'CompareAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\DWASFiles\Sites\<projname>\VirtualDirectory0\site\repository\<projname>.Common\<projname>.Common.csproj]

これらのコンパイル エラーは、プロジェクト内の別のアセンブリ (ビジネス ロジックを配置したアセンブリ) に対するものであることに注意してください。

グーグルで調べたとき、私が見つけた唯一の言及は、それらの参照に対して「ローカルコピー」フラグをtrueに設定する必要があることについてでした。これを試しましたが、それでも同じエラーが発生します。

これはすべてローカルで正常にコンパイルされます。何か案は?

アップデート

もう少し情報を追加するために、Git リポジトリにある私のプロジェクト構造は次のとおりです。

+ProjName
    ProjName.csproj
    web.config
    ...etc...
+ProjName.Common
    ProjName.Common.csproj
+ProjName.Tests
    ProjName.Tests.csproj
+packages <-- these are Nuget packages
ProjName.sln

Azure が示すコンパイル エラーは、ProjName.vcproj が失敗したことを示していますが、ProjName.Common アセンブリ参照を参照しています。

このレイアウトは、VisualStudio が作成したもの (つまり、webroot 用の追加のプロジェクト サブディレクトリ) であることに注意してください。

Git デプロイを行うときに Azure が何をするのか、よくわかりません。ProjName ディレクトリが webroot であることを認識し、ProjName.sln を解析して、ソリューション内にある他のアセンブリをコンパイルしますか (Visual Studio と同じ方法で)?

また、「bin」フォルダーを Git に追加していません。ただし、これをテストとして試しただけで、Azure が生成したコンパイル エラーは変わりませんでした。

4

3 に答える 3

13

2012 年 11 月 25 日更新: Dan のリポジトリを調べたところ、問題は、ライブラリ プロジェクトが NuGet パッケージではなく、GAC の Mvc 4 を使用していることです。NuGet パッケージに切り替えると、Azure で正常に動作します。

理論的には、MVC4 は Azure マシンの GAC にある可能性があり、これは問題になりません。そして多分彼らはある時点でそこにたどり着くでしょう。一般的には、MVC チームは、GAC にあるものに依存しない NuGet ベースのモデルをますます推し進めています。

元の答え:

通常、バイナリを git リポジトリにコミットすることは避け、代わりに NuGet に依存して取得する必要があります。これを実行し、Azure Web サイトで正常に動作するサンプル プロジェクトについては、https://github.com/KuduApps/Mvc4ApplicationFx40WithLibを参照してください。

しかし、あなたのプロジェクト構造に基づいて、あなたのプロジェクトは C++ (.vcproj) を使用しているようです。もしそうなら、考えられる問題は、Git 経由で発行する場合、Azure Web サイトで現在 C++ がサポートされていない可能性があることです。これまでのところ、人々は C# と VB を使用しなければならないため、これは発生していないと思います。それが本当に問題である場合は、https://github.com/projectkudu/kuduで問題を開いて、これを適切に追跡できるようにすることをお勧めします。

于 2012-11-22T17:03:15.113 に答える
2

したがって、私の .Common アセンブリには System.Web.Mvc と WebMatrix.WebData への参照がありましたが、Azure はそれをサポートしていないようです。Web プロジェクトではなく共通アセンブリでこれらの参照を使用するメンバーシップ コードがいくつかありました。それらを削除すると、エラーが削除されます。共通ライブラリがこれらの参照を必要としないように、コードを少しリファクタリングする必要があります。

于 2012-11-24T09:26:53.270 に答える
0

今日、紺碧のブートキャンプでこの問題が発生しました。

ソリューションで Nuget Package Restore を有効にし、それらの変更を github リポジトリにコミットすることで、デプロイを成功させることができました

于 2013-04-27T12:45:26.343 に答える