简体   繁体   English

使用Visual Studio发布Azure Web应用-不包括所有文件

[英]Azure web app publish with Visual Studio - not including all files

I have an MVC project being published to Azure from Visual Studio as a web app. 我有一个MVC项目作为网络应用程序从Visual Studio发布到Azure。 In the solution I have a project set up as a "plugin" which is used by the web application and installed using Unity DI. 在解决方案中,我有一个项目设置为“插件”,该项目由Web应用程序使用并使用Unity DI安装。 Locally this works but when I publish to azure the plugin files aren't being deployed. 在本地这是可行的,但是当我发布天蓝色时,并未部署插件文件。 This is how my solution and project structure is setup: 这是我的解决方案和项目结构的设置方式:

Solution MyProject
    >nuget
    >...
    >Plugins
        >Plugin.Widget.GoogleAnalytics
    >MyProject.Web
        >Properties
        >References
        >...
        >Plugins
            >bin
            >Plugin.Widget.GoogleAnalytics (excluded from project but copied to this directory after project is built above)
        >Views
        >...
        Web.config

Running locally if I delete Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics after is compiled the plugin doesn't appear. 如果在编译后删除Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics ,则在本地运行,则不会显示该插件。 If I copy the contents of Solution MyProject/Plugins/Plugin.Widget.GoogleAnalytics/bin back into Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics , the plugin reappears. 如果我将Solution MyProject/Plugins/Plugin.Widget.GoogleAnalytics/bin的内容复制回Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics ,则该插件会重新出现。

The problem is, when I publish to my azure web app, it doesn't include Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics . 问题是,当我发布到我的Azure Web应用程序时,它不包括Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics If I FTP that directory up from my computer is still doesn't load it after restarting the app. 如果我通过FTP下载该目录,则在重新启动该应用程序后仍无法从我的计算机加载该目录。

I've tried to include Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics in the project but it causes compilation problems since it's supposed to be added by DI and it also doesn't work after publish. 我试图将Solution MyProject/MyProject.Web/Plugins/Plugin.Widget.GoogleAnalytics在项目中,但是由于它应该由DI添加,因此会导致编译问题,并且在发布后也无法正常工作。

Is there a way to include the necessary files (not included in the project) during a publish so what works locally will work on azure? 有没有一种方法可以在发布过程中包括必要的文件(项目中未包括),以便本地有效的文件在Azure上有效? Or is there another way to go about this. 还是有另一种解决方法。

If I don't check the option on publish to Remove additional files at destination it usually throws this error when the site tries to load: 如果我不选择“发布”选项以Remove additional files at destination则在网站尝试加载时通常会引发此错误:

Method not found: 'Microsoft.Practices.Unity.IUnityContainer MyProject.Core.ContainerManager.GetConfiguredContainer()'

I've tried to debug that but it's very difficult since it only happens on the azure web app. 我已经尝试调试它,但是这非常困难,因为它仅在Azure Web应用程序上发生。

I found this question but it didn't give any information for this issues. 我找到了这个问题,但没有提供有关此问题的任何信息。

EDIT I was able to get the plugin to work on azure by following these steps. 编辑我可以按照以下步骤使插件在Azure上工作。 1) Run in dev environment locally in Debug mode. 1)在开发环境中以调试模式在本地运行。 2) Publish to azure as debug build. 2)发布为Azure,作为调试版本。 3) FTP web application plugin directory to azure. 3)将FTP Web应用程序的插件目录设为Azure。 4) Restart azure app. 4)重新启动azure应用。 It runs in azure but it's a debug build. 它以天蓝色运行,但它是调试版本。 5) Publish from local dev environment as release build. 5)从本地开发环境发布作为发布版本。

After this, I was able to publish as release build and check Remove additional files at destination . 之后,我就可以发布为发布版本,并选中“ Remove additional files at destination This removes the plugins in azure. 这会以天蓝色的方式删除插件。 Then I FTP'd the web application plugin directory to azure and start and stop web app and it works. 然后,我通过FTP将Web应用程序插件目录设置为Azure,并启动和停止Web应用程序,并且它可以正常工作。 Maybe I can take the debug steps out of this but this is working now. 也许我可以取消调试步骤,但是现在可以正常工作了。

Heinrich, 海因里希,

Can you please try this below step and see it works. 您可以在下面的步骤中尝试一下,看看它是否有效。

  • Make sure you set the build action to Content and they will get deployed. 确保将构建操作设置为“内容”,它们将被部署。
  • Try deploying in release mode. 尝试以发布模式进行部署。

Hope it helps. 希望能帮助到你。

MV MV

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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