简体   繁体   中英

System.Web.Helpers not being published by Visual Studio 2012

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.

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

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.

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.

  • 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.

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.

Any ideas?

UPDATE

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

How about this:

  1. Right-click on the MVC project in solution explorer.
  2. Add Deployable Dependencies
  3. Tick MVC

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.

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.

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)\bin\)" Importance="high" />
    <Exec Command="ECHO Going to copy from '$(ProjectDir)\_bin_PublishAssemblies'" />
    <Exec Command="xcopy $(ProjectDir)\_bin_PublishAssemblies\* $(_PackageTempDir)\bin\ /Y" />
  </Target>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM