Azure git部署 - 缺少第二个程序集中的引用

Dan*_*Dan 9 git deployment asp.net-mvc azure web-deployment

我正在尝试将Bitbucket部署设置为Azure网站.我成功地将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]
Run Code Online (Sandbox Code Playgroud)

请注意,这些编译错误是针对我的项目中的另一个程序集(我放置业务逻辑的程序集).

当谷歌搜索时,我发现唯一提到的是必须为这些引用设置"本地副本"标志为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
Run Code Online (Sandbox Code Playgroud)

Azure显示的编译错误表明它的ProjName.vcproj失败了 - 但它们引用了ProjName.Common程序集引用.

请注意,此布局是VisualStudio创建的(即webroot的额外项目子目录).

我不确定Azure在进行Git部署时会做什么.它是否认识到ProjName目录是webroot,还解析ProjName.sln编译解决方案中的任何其他程序集(与Visual Studio相同)?

另外,我没有向Git添加任何"bin"文件夹.但是,我只是尝试将其作为测试,并没有改变Azure生成的编译错误.

Dav*_*bbo 13

更新时间:11/25/2012:在查看Dan的回购之后,问题是库项目正在使用GAC中的Mvc 4而不是使用NuGet包.切换到NuGet包使其在Azure上正常工作.

理论上,MVC4可能位于Azure计算机上的GAC中,这不是问题.也许他们会在某个时候到达那里.虽然一般情况下,MVC团队正在越来越多地推动基于NuGet的模型,而不依赖于GAC中的内容.

原始答案:

通常,您应该避免将二进制文件提交到您的git仓库,而是依靠NuGet来检索它们.请参阅https://github.com/KuduApps/Mvc4ApplicationFx40WithLib以获取执行此操作的示例项目,并在Azure网站中正常运行.

但根据您的项目结构,我发现您的项目似乎使用C++(.vcproj).如果是这样,那么可能的问题是,当通过git发布时,Azure网站今天可能不支持C++.到目前为止,我认为这不会出现,因为人们必须使用C#和VB.如果这确实是问题,那么我建议您在https://github.com/projectkudu/kudu上打开一个问题,以便我们能够正确跟踪这个问题.