使用FSharp.Data天青网站的Web应用程序部署 [英] Deployment of a web application using FSharp.Data to Azure Websites
问题描述
这是一个类似的问题<一href=\"http://stackoverflow.com/questions/13095818/how-do-i-deploy-a-web-application-using-f-to-azure-web-site\">How我使用部署F#天青网站的Web应用程序。我的C#/ F#MVC项目采用FSharp.Data的NuGet包,以及部署过程失败的消息
This is a similar question to How do I deploy a web application using F# to Azure Web Site. My C#/F# MVC project uses the FSharp.Data NuGet package, and the deployment process fails with the message
无法找到程序集FSharp.Data,版本= 1.1.4.0,文化=中性公钥=空。
Could not locate the assembly "FSharp.Data, Version=1.1.4.0, Culture=neutral, PublicKeyToken=null".
唯一的有效解决方案,我可以看到的是所有的NuGet引用(FSharp.Data,FSharp.Data.DesignTime,FSharp.Data.Experimental,FSharp.Data.Experimental.DesignTime)有明确提及的取代的DLL文件,和复制本地设置为true。我不愿扔的NuGet婴儿连同这样的洗澡水。有一个聪明的方法吗?另外,有一个开放的问题,我可以加我的票?
The only effective workaround I can see is to replace all of the NuGet references (FSharp.Data, FSharp.Data.DesignTime, FSharp.Data.Experimental, FSharp.Data.Experimental.DesignTime) with explicit references to the DLLs, and Copy Local set to true. I am loath to throw the NuGet baby out with the bathwater in this way. Is there a cleverer way? Alternatively, is there an open issue to which I can add my vote?
推荐答案
您可以添加的&LT; dependentAssembly&GT; 元素添加到的web.config
来确保 FSharp.Data当你的项目部署到Azure中包含
组装。我用天青混合部署F#/ C#ASP.NET MVC项目时,在此之前技术;它已经有一段时间,但我不认为我不得不改变复制本地
设置上引用的程序集(我通过的NuGet添加)。
You can add a <dependentAssembly> element to your web.config
to make sure the FSharp.Data
assembly is included when your project is deployed to Azure. I've used this technique before when deploying mixed F#/C# ASP.NET MVC projects to Azure; it's been a while, but I don't think I had to change the Copy Local
setting on the referenced assemblies (which I added via NuGet).
反正你需要添加应该是这个样子的条目:
Anyway, the entry you need to add should look something like this:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Data" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
根据罗布的评论
这是他仍然得到同样的错误消息,here're下一步我想借此来诊断问题。
Based on Rob's comment that he's still getting the same error message, here're the next steps I would take to diagnose the issue.
- 构建Azure的部署包(你不需要部署)。当它完成后的建筑,找到部署包文件(
* cspkg
);这其实只是一个zip文件,这样的内容解压到一个文件夹,例如,使用 7-ZIP 。在提取的文件夹,应该有一个文件与* cssx
扩展,是比别人大得多。它也是一个压缩文件,解压所以到另一个文件夹,然后浏览与Windows资源管理器文件夹。从那里,进入sitesroot
文件夹,那么0
文件夹中。您现在应该在看你的网站的根目录下(即文件/文件夹是会被复制到C:\\的Inetpub \\ wwwroot文件
在Web服务器上)。检查斌
文件夹 - 你看到FSharp.Data code>组装吗?如果不是,这是一个构建/包装的问题,而不是服务器的问题;如果你看到
FSharp.Data code>装配,进入到下一个步骤。
- 您的项目部署到Azure中,然后远程桌面到您的项目被托管的实例之一。 (有启用的情况下远程桌面的特殊程序 - 如果你还没有这样做呢,你需要在继续之前这样做。)一旦你登录,你可以打开的事件查看器(下的管理工具的);看的应用程序的下记录的 Windows日志的 - 是否有任何ASP.NET错误吗?如果是这样,点击它们,看看错误信息,它可能包含有关不能够解决
FSharp.Data code>组装一个.NET异常消息。如果是这样,浏览到
C:\\的Inetpub \\ wwwroot的\\
并确保FSharp.Data code>是<$该网站的C $ C>斌
文件夹中。如果是,请继续执行下一步。 -
如果在
FSharp.Data code>组件被打包并与您的Web项目沿着正确部署,那么有可能是与它(或一个所产生的一些问题它的依赖)是当你的项目是在.NET 4.5中运行的.NET 4.0组件。当登录到Azure的实例(通过远程桌面),你可以启用日志记录的融合,并使用融合日志查看器跟踪CLR是如何尝试加载程序集。如果你这样做追查的问题,有可能的方式来解决这将是添加一个
&LT; bindingRedirect&GT;
元素中的&LT; dependentAssembly&GT; < /你在你的
进入>的web.config
。以下是我这样做是为了获得原始的F#PowerPack中(其中有针对性FSharp.Core
的.NET 2.0版本)在我的F#的工作/ C#项目在.NET 4.0:
- Build the Azure deployment package (you don't need to deploy it). When it's finished building, find the deployment package file (
*.cspkg
); this is actually just a zip file, so extract the contents into a folder, e.g., with 7-zip. In the extracted folder, there should be one file with the*.cssx
extension which is much larger than the others; it's also a zip file, so extract it into another folder, then browse into that folder with Windows Explorer. From there, go into thesitesroot
folder, then the0
folder. You should now be looking at the root of your website (i.e., the files/folders that'll be copied toC:\inetpub\wwwroot
on the web server). Check thebin
folder -- do you see theFSharp.Data
assembly there? If not, this is a build/packaging problem, not a server problem; if you do see theFSharp.Data
assembly, proceed to the next step. - Deploy your project to Azure, then Remote Desktop into one of the instances your project is being hosted on. (There's a special procedure for enabling Remote Desktop on the instances -- if you haven't done this yet, you'll need to do so before continuing.) Once you're logged in, you can open Event Viewer (under Administrative Tools); look at the Application log under Windows Logs -- are there any ASP.NET errors there? If so, click them and look at the error message, it may contain a .NET exception message about not being able to resolve the
FSharp.Data
assembly. If it does, browse toC:\inetpub\wwwroot\
and make sureFSharp.Data
is in thebin
folder of the website. If it is, proceed to the next step. If the
FSharp.Data
assembly is being packaged and deployed correctly along with your web project, then there could be some issue arising with it (or one of it's dependencies) being a .NET 4.0 assembly when your project is running on .NET 4.5. While logged in to the Azure instance (via Remote Desktop) you could enable Fusion logging and use the Fusion log viewer to trace how the CLR is attempting to load the assembly. If you do track down the issue, the likely way to fix it will be to add a<bindingRedirect>
element within the<dependentAssembly>
entry you created in yourweb.config
. Here's how I did it to get the original F# PowerPack (which targeted the .NET 2.0 version ofFSharp.Core
) working in my F#/C# project on .NET 4.0:
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
这篇关于使用FSharp.Data天青网站的Web应用程序部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!