部署MVC4项目时出错:找不到文件或程序集

3
过去,我使用Visual Studio 2012的“发布到AWS”菜单项将我的MVC4网站部署(到AWS Elastic Beanstalk)。

现在,程序在本地编译和运行,但是无法成功部署。从错误消息来看,它似乎正在寻找未包含在当前项目中并且不是当前项目的引用的文件。

在一些尝试部署时,错误是绝对存在于文件系统和项目中的文件无法找到。 VS似乎正在搜索错误的位置和不需要的文件。

Commencing deployment for project MyWebApp.UI
...building deployment package obj\Debug\Package\Archive...
...package build 'CopyPipelineFiles': error in 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets' at (2567,5): Copying file Content\bootstrap-fam-fam\css\fam-icons.css to obj\Debug\Package\PackageTmp\Content\bootstrap-fam-fam\css\fam-icons.css failed. Could not find a part of the path 'C:\MyWebApp\MyWebApp\MyWebApp.Model.Test\obj\Debug\Package\PackageTmp\Content\bootstrap-fam-fam\css\fam-icons.css'.
...build of project archive failed, abandoning deployment
Commencing deployment for project MyWebApp.UI
...building deployment package obj\Debug\Package\Archive...
...package build 'ResolveAssemblyReference': warning in 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets' at (1605,5): Could not resolve this reference. Could not locate the assembly "WebActivator". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
...package build 'ResolveAssemblyReference': warning in 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets' at (1605,5): Could not resolve this reference. Could not locate the assembly "WebGrease". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
...package build 'CopyPipelineFiles': error in 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets' at (2185,5): Copying file Web.config to obj\Debug\CSAutoParameterize\original\Web.config failed. Could not find file 'C:\MyWebApp\MyWebApp\Amazon\obj\Debug\CSAutoParameterize\original\Web.config'.
...build of project archive failed, abandoning deployment

我清理了这个项目,修复了VS2012,但是错误仍然存在!


我也遇到了同样的问题(尽管我在组装软件包时也遇到了问题)。看起来它正在 c:\WINDOWS\System32 中寻找 web.config...软件包构建“ResolveAssemblyReference”:'Web.config' 中的错误(位于 (0,0) 处):应用程序配置文件“Web.config”无效。找不到文件 'C:\WINDOWS\system32\Web.config'。 - kingdango
请查看更新后的答案。 - Jonathan
1个回答

7

[编辑] 如Jim Flanagan在评论中建议的那样,这是一个R#(Resharper 8.2)集成问题。当关闭R#(工具|选项|Resharper |暂停)时,部署成功。(请参见http://youtrack.jetbrains.com/issue/RSRP-411186#tab=Similar%20Issues

R#还建议(http://youtrack.jetbrains.com/issue/RSRP-411186):
打开/关闭使用msbuild获取项目引用的能力。您可以在R# - >选项 - > VS集成 - >使用msbuild获取引用中找到此选项。
我无法在我的系统上找到该选项(没有VS Integration选项;只有“键盘和菜单”),但在部署之前完全禁用R#就能顺利运行。


请告诉我,如果您找到了不同的问题答案。 - Pavel
2
这可能是ReSharper和由AWS Visual Studio Toolkit运行的msbuild的问题。一些AWS用户在升级到ReSharper 8.2后遇到了这个问题。这是JetBrains的问题:http://youtrack.jetbrains.com/issue/RSRP-411186。我无法使用任何组合的OS / Visual Studio / ReSharper / AWS Toolkit版本重现此问题。 - Jim Flanagan
Jim的解决方案非常完美...我更新了答案。谢谢,Jim! - Jonathan
我遇到了类似的问题,错误信息是[应用程序配置文件"Web.config"无效。找不到文件'某些项目依赖项的路径,该路径不存在或不需要web.config\Web.config']。禁用Resharper解决了这个问题。 - Jon H
我没有ReSharper,但我仍然有同样的问题,尽管我不确定关于msbuild。 - AbdallahRizk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接