Facing issue with application after Deployment to Azure App Service - asp.net-mvc

we are following plugin architecture, so we are having other projects which can plugin into the main web application.
Folder structure:
--MVC Application
-- bin
--Plugins
-- Plugin1
-- dlls
-- Plugin2
--dlls
When I published my MVC application to Azure App service.The dlls present in the main web application only got copied.How can I move the dlls present in my plugins folder.
When I try to run the application it is not loading the scripts and dlls present in other plugin folders.
Can some one please let me know how can I solve the issue and these plugins are dynamic.
Based on the post build event, we are copying the dlls and scripts to respective plugin folders.

Related

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. In the solution I have a project set up as a "plugin" which is used by the web application and installed using 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. 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.
The problem is, when I publish to my azure web app, it doesn't include 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.
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.
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? 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:
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.
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.
1) Run in dev environment locally in Debug mode.
2) Publish to azure as debug build.
3) FTP web application plugin directory to azure.
4) Restart azure app. It runs in azure but it's a debug build.
5) Publish from local dev environment as release build.
After this, I was able to publish as release build and check 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. 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

Deploy ASP.NET Application while Hiding Sources

When we deploy our ASP.NET MVC application all sources, controllers, views, etc. are copied.
This is not a problem when we deploy on our server, but when we are going to deploy a copy into external servers and we don't want to share our code.
Does not exist a tool to package into libraries? .NET Core seems to deploy into DLL files, but I don't find that functionality on ASP.NET MVC.
Does not exist a tool to package into libraries?
Yes.
This is what publishing the application does - it prepares the application for deployment. When you publish, it will compile the source code and prepare only the assets your application needs to run into a deployment folder.
It compiles the source into libraries. Views are only compiled if you use the precompile views option, otherwise they are distributed as files.
Use the Publish tool to deploy to a local folder. The exact options available depend on your app type. In Solution Explorer, right-click your project and choose Publish, and then choose Folder. For more information, see Deploy to a local folder.
Tutorial: Publish your Hello World application with Visual Studio 2017
You can combine publishing with IIS Web Deploy in order to easily automate the process of deploying your web site.

Using Octopack on a TFS build with a website + windows service

I have a website, a windows service, and some shared class libraries in a single Visual Studio solution. I use Octopack on both the website and windows service, and on my machine these builds work as expected.
When using the TFS Build Server, the website nuget package is generated as expected, but the windows service nuget package contains all files from the website, as well as the service. E.g. it includes the _PublishedWebsites folder as well.
This is because TFS uses a single location to build projects.
What is the best way around this?
I know this question has since been closed, but I cam across this issue and solved it in a different way.
My solution is compromised of a number of websites and windows services and had the same issue of the OctoPack created nuget packages including all the solution assemblies from the 'pooled' output folder when building with Team Build. The reason the nuget packages get all the assemblies is OctoPack uses the outdir msbuild argument as the location to include assemblies from.
The way I got around it was to use the msbuild argument GenerateProjectSpecificOutputFolder=true. This instructs Team build to create a folder for each project in your output folder in the same way Visual Studio uses the bin folders under each project when building locally.
My build definition msbuild arguments looks like:
/p:GenerateProjectSpecificOutputFolder=true;RunOctoPack=true;OctoPackPublishPackageToFileShare=\\<NugetServer>
I currently just push the packages onto a shared folder but the OctoPackPublishPackageToHttp and OctoPackPublishApiKey parameters can also be used.
The benefit of this solution over the one above is you don't need to specify the files to include the nuget package.
Hope this helps someone.
I ended up using this nuget package to ensure the console app built to a seperate directory on the TFS server.
https://nuget.org/packages/PublishedApplications/2.1.0.0
I then had to specify in the nuspec file, which files should be included for the console app. e.g
This works and I can now deploy using Octopus deploy.
The downside of this apporach is that the PublishedApplications build only works on the TFS build server, so I can't build the project locally in release mode. Still looking on how to overcome this.

Continous Integration with ASP.NET MVC and TFS

I have an ASP.NET MVC 3 application. This application is hosted in TFS. I have setup a build server. When a checkin happens, my code is complied and dropped in a folder on my test server. The drop folder is an IIS application folder. The goal is when a user visits http://[myTestServer]/MyProject, they should see the latest compiled version of the app. In an attempt to do this, I'm dropping files in //[myTestServer]/c$/inetpub/www/myProject/. However, I'm getting more than I bargained for.
I've noticed that the build server puts a bunch of assemblies and creates 2 directories: _PublishedWebsites and logs. _PublishedWebsites contains two directories: MyProjectName and MyProjectName_Package. From what I can tell MyProjectName contains the files that I want put in //[myTestServer]/c$/inetpub/www/myProject/. What am I doing wrong?
How do I setup it up such that when a user visits http://[myTestServer]/MyProject, they see the latest compiled version of the app?
Have a look at Microsoft's Web Deploy for deployment of Web applications and Web sites to IIS servers.
This tutorial describes in detail how to configure TFS for Web Deployment:
Configuring Team Foundation Server for Web Deployment
Creating a Team Project in TFS
Adding Content to Source Control
Configuring a TFS Build Server for Web Deployment
Creating a Build Definition That Supports Deployment
Deploying a Specific Build
Configuring Permissions for Team Build Deployment

Separate console application project outputs in TFS drop folder, similar to _PublishedWebSites

I have a large solution with 10+ web applications and 10+ console and windows service applications.
When building All.sln, in the drop location, i've got single folder with all console application dlls, and web application dlls mixed.
Also, i've got _PublishedWebsites folder, which contains nicely separated web applications in their own folders, ready to deploy.
How to get console applicaitons in their own folders, each with only necessary referenced dlls, just the way web applications are separated in _PublishedWebsites?
Looks like it's possible with custom 'master' msbuild file:
msbuild SLN and still get separate project outputs?, but how to achive the same with regular TFS 2010 build?
there's a NuGet package you can install that will do this.
see http://www.nuget.org/packages/publishedapplications

Resources