【发布时间】:2012-11-05 23:05:30
【问题描述】:
我正在尝试将 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]
请注意,这些编译错误针对我项目中的另一个程序集(我放置业务逻辑的程序集)。
在谷歌搜索时,我发现的唯一提及是必须将这些引用的“本地副本”标志设置为 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 的额外项目子目录)。
我不太确定 Azure 在进行 Git 部署时会做什么。它是否识别 ProjName 目录是 webroot,并解析 ProjName.sln 编译解决方案中的任何其他程序集(与 Visual Studio 相同)?
另外,我没有向 Git 添加任何“bin”文件夹。但是,我只是将其作为测试进行了尝试,它并没有改变 Azure 产生的编译错误。
【问题讨论】:
-
检查this solution。 FTP 是一款出色的 Windows Azure 网站调试工具。
-
也许我误解了 git repo 中需要哪些文件。我没有将我的 bin 文件夹签入 git(我认为 Azure 以与 VS 在本地编译时相同的方式生成它?)。当我 FTP 进入时,
.Common(这是我的业务逻辑程序集)有一个空的 bin 文件夹(可能是因为它无法编译)。而作为我的 web 根目录的文件夹根本没有 bin 目录(可能是因为编译失败的 .Common 是必需的依赖项)。 -
@丹。这取决于。您是否使用任何不在普通 Windows 安装中的 dll,您需要提供它们。您在设置时是否遵循本指南? windowsazure.com/en-us/develop/net/common-tasks/…
-
@MagnusKarlsson 我没有使用任何不在 nuget "packages" 目录中的东西,或者解决方案中包含的
.Common 项目(所以我认为 Azure 会编译它)。
标签: asp.net-mvc git deployment azure web-deployment