asp.net-mvc - 当 Copy-Local 设置为 True 时,为什么 Azure 部署中缺少 DLL?

标签 asp.net-mvc azure visual-studio-2013 azure-devops

我在 Visual Studio 2013 中设置了 ASP.NET MVC v4 项目。

我使用 Visual Studio Online 在 Git 中托管该项目。我使用 Azure 部署配置文件创建了一个构建定义,以便我可以运行自动构建,该构建也会自动部署站点。

但是,在明显成功的部署之后,我收到以下错误:

Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我已经通过FTP检查了该网站,System.Web.Mvc.dll文件肯定丢失了。

但是,MVC 是作为 NuGet 包安装的,为解决方案启用了 NuGet 包还原,并设置了“复制本地”作为引用。如果我在本地构建解决方案,则 DLL 会正确复制到输出文件夹。

我检查了 Visual Studio Online 构建日志,可以看到以下内容...

...

Installing 'Microsoft.AspNet.Mvc 4.0.30506.0'.

...

Successfully installed 'Microsoft.AspNet.Mvc 4.0.30506.0'.

...

所以 - 我不明白为什么 DLL 没有部署到 Azure。

任何帮助将不胜感激!

最佳答案

最新的 MVC 4 版本是 4.0.0.1。检查您的项目引用是否正确指向 NuGet 中的版本,而不是 GAC 中的版本。

这篇 MSDN 博客文章可能会有所帮助:http://blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx

您还可以尝试将重定向添加到您的 web.config:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

关于asp.net-mvc - 当 Copy-Local 设置为 True 时,为什么 Azure 部署中缺少 DLL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28928654/

相关文章:

reactjs - 如何在 Azure 静态 Web 应用中手动部署 NextJS SPA

c# - VS2013 : How to make PostBuildEvent depend on the chosen platform?

c# - 上传图像和模型 ASP.NET MVC 4

asp.net - 为 Web UI 实现有限状态机

c# - 在 ASP.NET MVC 中单击按钮时呈现局部 View

python - 如何使用 Azure Cloud Function (python) 中的用户管理身份向 Azure KeyVault 发出请求?

azure - 配置主机池加入域失败

c - 是否可以使用 Visual Studio 2013 Express for Windows 查找 C 函数的堆栈深度?

visual-studio-2013 - 模式为“发布”而不是“调试”时,Visual Studio Web Deploy会提示您输入密码

asp.net-mvc - Forms身份验证登录Url