Visual Studio 2012 未发布 System.Web.Helpers [英] System.Web.Helpers not being published by Visual Studio 2012

查看:20
本文介绍了Visual Studio 2012 未发布 System.Web.Helpers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全被这个难住了.我通过 google stack overflow 找到的想法对我不起作用,我不知道为什么.

I'm totally stumped by this one. The ideas that I've found through google stack overflow don't work for me and I've no idea why.

我们最近将项目升级到 Visual Studio 2012 和带有 .NET 4.5 的 MVC 4,现在它无法正确发布.

We recently upgraded the project to Visual Studio 2012 and MVC 4 with .NET 4.5 and now it won't publish properly.

我们有另一个分支,它只是在 Visual Studio 2012 中发布项目,而没有升级到 MVC4 或 .NET4.5,这似乎有效,所以我猜这不是 Visual Studio 的问题.只是在我们的项目中设置 MVC 4 的方式.MVC 3 是通过直接从我们在源代码管理中(但在任何项目之外)创建的 lib 文件夹中引用 DLL 来添加的.MVC 4 是通过 NuGet 添加的.

We have another branch that just has the project publishing in Visual Studio 2012 without the upgrade to MVC4 or .NET4.5 and that seems to work, so I'm guessing it isn't a Visual Studio issue. Just something with the way that MVC 4 is set up in our project. MVC 3 was added by referencing the DLLs directly from a lib folder we had created in the source control (but outside of any projects). MVC 4 is added via NuGet.

问题是 System.Web.Helpers(以及其他)没有出现在已发布应用程序的 bin 目录中.这意味着当它放在测试服务器上时,它不会运行,因为缺少 DLL.

The issue is that System.Web.Helpers (amongst others) don't appear in the bin directory of the published application. This means that when it is put on the test server it won't run as the DLL is missing.

  • 我已将 Copy Local 设置为 TRUE(实际上,它已经设置为 TRUE,但如果关闭并再次打开,我将其关闭).我还在某处读到,如果文件存在于 GAC 中,则此设置无关紧要,它不会复制.但是,我已经检查过,它不在 GAC 中.
  • 我已确保 MVC 应用程序中的引用指向 NuGet 包文件夹中的文件版本.(它不是最初的,但我手动编辑了 csproj 文件来做到这一点,因为删除和读取 NuGet 包没有帮助)
  • 我添加了一个构建后事件来复制相关文件(这不会影响发布,尽管它们在项目的 bin 目录中)
  • 我尝试按照 Phil Haack 的博客,但似乎在 Visual Studio 2012 中不起作用.
  • 我尝试修改 csproj 文件(它只是一个 MSBuild 文件)来为我复制相关文件,根据这个 SO 答案.但无论出于何种原因,它也不想工作.
  • I've set Copy Local to be TRUE (actually, it already was, but I turned if off and on again). I also read somewhere that if the file exists in the GAC it won't matter what this setting is, it won't copy. However, I've checked and it isn't in the GAC.
  • I've ensured that the reference in the MVC application was pointing to the version of the file in the NuGet packages folder. (It wasn't originally, but I've manually edited the csproj file to do that as removing and readding the NuGet package didn't help)
  • I've added a post-build event to copy the relevant files (which doesn't affect the publish, although they are in the project's bin directory)
  • I've attempted to put a _bin_deployableAssemblies folder in place, as per Phil Haack's blog, but it seems this doesn't work in Visual Studio 2012.
  • I've tried modifying the csproj file (which is just an MSBuild file) to copy the relevant files for me, as per this SO answer. But for what ever reason that doesn't want to work either.

我已经没有什么可以尝试的了.好吧,我总是可以像其他地方的一些 SO 答案所建议的那样手动复制文件,但这违背了目的.

I've run out of things I can try. Well, I can always copy the file manually as some SO answers have suggested elsewhere, but that defeats the purpose.

有什么想法吗?

更新

在上面的要点中针对我尝试过但对我不起作用的内容添加了更多内容.

Added more things in the bullet points above for things I've tried that don't work for me.

推荐答案

我找到了答案.这有点麻烦,因为我无法让 MSBuild 复制命令起作用,所以我使用 Exec 命令让 xcopy 为我进行复制.

I've found an answer. It is a bit of a hack because I couldn't get the MSBuild copy command to work, so I used the Exec command to get xcopy to do the copying for me.

首先,我在项目中添加了一个名为 _bin_PublishAssemblies 的文件夹,并将我需要发布的程序集放入其中,而构建过程尚未启动.

First of all I added a folder called _bin_PublishAssemblies to the project and put in there the assemblies that I need to publish that the build process is not picking up already.

然后我在 csproj 文件的末尾添加了以下内容:

Then I added the following towards the end of the csproj file:

  <Target Name="AfterBuild">
    <Message Text="Build | Copying assemblies to output folder ($(OutputPath))" Importance="high" />
    <Exec Command="ECHO Going to copy from '$(ProjectDir)\_bin_PublishAssemblies'" />
    <Exec Command="xcopy $(ProjectDir)\_bin_PublishAssemblies* $(OutputPath) /Y" />
  </Target>
  <Target Name="CopyBinFiles" AfterTargets="CopyAllFilesToSingleFolderForPackage" BeforeTargets="MSDeployPublish">
    <Message Text="Deploy | Copying assemblies to output folder ($(_PackageTempDir)in)" Importance="high" />
    <Exec Command="ECHO Going to copy from '$(ProjectDir)\_bin_PublishAssemblies'" />
    <Exec Command="xcopy $(ProjectDir)\_bin_PublishAssemblies* $(_PackageTempDir)in /Y" />
  </Target>

这篇关于Visual Studio 2012 未发布 System.Web.Helpers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆