deploy website with production configuration automatically in Visual Studio 2010 - asp.net-mvc

I have a question regarding Visual Studio 2010 publish feature which is used after you create a website (MVC framework) to push your dev changes to the live site.
I've never worked with MVC until a few weeks ago and
I've noticed that before pushing the website code I have to change everywhere where I have localhost in the code and replace it with the domain name I'm pushing to. Then if I want to debug anything on my local machine I have to revert everything back to localhost from domain name.
Q: Is there a way to not do this back and front url changing?
Basically I think it boils down to needing a software package or sth that knows to deploy the website with production configuration.
Maybe have a local branch and a live branch? This involves merging files all the time.
Thanks :)

I am not sure it works with MVC, but one approach we use for web services development is to use the web.config transformations.
This means that the normal development stuff is in Web.config and we have separate configurations depending on the deployment environment Web.staging.config and Web.production.config.

Related

Razor MVC 5 ASP.NET form editing with missing Controllers & Models folders on server

Hope you guys can give me a clue.
I recently got onto this web developer role and the former person left the company long ago. I'm completely a newbie on MVC or .net development. My knowledge area would be: html, css, java, jsp, php and etc.
There is a web form I need to redesign and I have watched video on Lynda.com:
Running with ASP.NET
ASP.NET MVC 5 Essential Training
c#
Long story short, the production development environment is set as:
use Visual Studio 2013 to develop, then check in and build.
logon to Octopus Deploy to deploy to Production or Staging
dev-portal(on the left) is the live production source code available on the VS 2013 on the local machine, this is set up by a genius guy I couldn't reach; 4.2.11_9(on the right) is the staging site I set up on the RD testing server.
I know I need to edit controller and model and view pages to modify the page, however the folders that on the server (we host these pages on our own server) is missing quite a bit. I have no idea where are those folder are hidding.
And also text strings are stored in Resources\Resources.resx
Can anyone give me a clue? This is far more complex for me to figure out, comparing to the video scenario demo on the Lynda.com example.
Many thanks!!!
Edit the code using Visual Studio and test on your local machine.
Check your code into TFS. Confirm that a server build has occurred or schedule a new build.
Log into Octopus Deploy and confirm a new release was recently created.
Deploy your release to staging. Confirm the changes. Then deploy to Prod.

How do you deploy a MVC4 .net app to production WITHOUT Web Deploy

I'm trying to deploy one of the default template apps that VS2012 generates for MVC4 to a production server (not on Azure).
It turns out that I'm not smart enough to figure out how to get Web Deploy working. After spending an hour on diagnosing different 404s, 403s, and 401s, I am ready to either ditch Web Deploy altogether, or start my project using PHP instead.
Can I just copy and paste my files and put them somewhere?
I'm fine with manually updating the database schema.
Anything else that needs to be updated?
You can publish directly to "File System" via "Publish" menu in VS (choose folder on production server). Then create WebApp on IIS with this folder (on the server) choose ApplicationPool 4.0 open port for your application if needed and start it.
What in the world makes you even think you need to use web deploy? You do realize that the web publishing wizard has several options to choose from, including FTP, file system, etc... I don't see how you could miss these.

Azure cloud service publishing - where does it go?

I created an asp.net mvc project in VS. I created an azure cloud service. Within the VS solution I added an azure project to enable me to publish to my cloud service. The cloud service has a web role and it’s published to a production environment. When I publish the project, I have my domain .cloudapp.net and I can then view my published project from a browser.
Job done. All good so far.
What I’m unclear on (and this is partly because my azure and asp.net mvc knowledge is limited) is where the project files actually reside (and the file/folder structure) and how to access them? I know they are on an IIS server somewhere but that’s about it.
With ‘traditional’ websites you have a webserver, a wwwroot folder and you stick your web pages etc into them and can see/access them through ftp etc.
Apart from wanting to know the answer to the above question I actually want to farm out the web ui (view) part to a web developer whilst I concentrate on the back end stuff. He doesn’t have visual studio so I’m unclear on how to best approach this?
I’ve noticed on the windows azure publish summary within my solution that you can enable remote desktop and enable web deploy which I suspect may be of help to me but as the solution is all working fine at the moment and I’m demoing it to a client tomorrow I’m a bit reluctant to make any last minute changes..as I’m sure we’ve all suffered the consequences of that before.
What I’m unclear on is where the project files actually reside
(and the file/folder structure) and how to access them?
As you have mentioned, these files reside on the server itself. If you connect to your server via Remote Desktop, you can see the files under D:\sitesroot folder (actual name of the folder can be found by launching IIS Manager on that server).
Having said that, it is not recommended to make changes to the files directly on the server. This is because if your server goes bad for any reason, Microsoft will provision a new server for you and it takes the code from the package file when you last deployed your application. This the changes you have made on that server will be lost.
Regarding your other question about having somebody focus on front-end development, I'm pretty sure you don't want him to working on production server directly. I'm assuming you have a centralized code repository somewhere where everybody checks in their code and then you build stuff and then deploy it.

MissingManifestResourceException on one server, not on others

I've been pulling my hair out over this one.
Our staging server (Windows Server 2008 R2 Standard) has recently stopped cooperating. To be more specific, when our ASP.NET MVC 3 site is started, it gives the exception
MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Resources.TranslatedUrl.resources" was correctly embedded or linked into assembly "App_GlobalResources" at compile time, or that all the satellite assemblies required are loadable and fully signed.
which means the site goes through startup, but then encounters an error when trying to register our (customized) translatable routes using GlobalResources. The same code base works flawlessly on our demo server, virtual machine server and Visual Studio's development server. I even did a revert of the code base to a point in time where the site was demonstrably working, but no luck. This leads me to believe the problem is with the server itself, or IIS 7, in which the site runs.
Problem is, no one has (to my knowledge) done any reconfigurations of IIS or the server. I've been moving our CI from CruiseControl.net to TeamCity, but the compile and setup is done on a separate server, which, once all compilation and configuration is complete, moves the files to the staging server using Web Deploy. Is it possible that Web Deploy could, in some way, have altered the config of IIS or the server?
I suppose it is also possible that our hosting provider could have made some changes I don't know about, but it seems unlikely.
Any ideas? I'm all out of them myself.

How to publish an ASP.NET MVC website

I've a site that I'd like to publish to a co-located live server. I'm finding this simple task quite hard.
My problems begin with the Web Deploy tool (1.1) giving me a 401 Unauthorized as the adminstrator because port :8172 comes up in the errors and this port is blocked - but the documentation says "The default ListenURL is http://+:80/MsDeployAgentService"!
I'm loathe to open another port and I've little patience these days so I thought bu66er it, I'll create a Web Deploy package and import it into IIS on the server over RDP.
I notice first that Visual Studio doesn't use a dialog box to gather settings, or use my Publish profiles but seems to use a tab in the project properties, although I think these are ignored when importing the package anyway?
I'm now sitting in the import wizard with Application Path and Connection String. I've cleared the conn string as I think this is for some ASP stuff I don't use but when I enter nothing in the Application Path, the wizard barks at me saying that basically I'm a weirdo because most people publish to folders beneath the root site.
Now, I want my site to be site.com/Home/About and not site.com/subfolder/Home/About and I think being an MVC routed site that a subfolder will introduce other headaches. Should I go ahead and use the root?
Finally, I also want to publish a web service to www.site.com/services/soap which I think IIS can handle.
While typing this question, Amazon have delivered my IIS 7 Resource Kit, and I've been scouring the internet but actually I'm getting more confused.
Comment here seems to show consensus opinion that Publish isn't for production sites and that real men roll their own.
ASP.NET website 'Publish' vs Web Deployment Project
...I guess this was pre- Web Deployment Tool era?
I'm going to experiment on a spare box for now but any assistance is welcome.
Luke
UPDATE
The site was imported (to the root) manually with Web Deploy and it worked. If you get the error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' " its because your app pool is 4.0 and should be 2.0.
If you are using VS 2010, may I recommend Scott Hanselman's Web Debloyment Made Awesome?
http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx
Even if you are using VS2008, there are nice concepts there that will probably help.
I've experienced the same frustration and trouble with this as well. Coming from a Java web background where we can package everything as a single WAR and toss it on the server, the deployment process with ASP.NET seems archaic.
I currently have a python script that uses FTP to transfer the needed files to my test instance on the remote server. I have another python script that transfers those files to my live site. These scripts are smart enough to take care of differences between some of the configuration files etc..
I've found it much easier than trying to setup permissions or using the Microsoft deploy tools.
Hi you can use filezilla software to upload

Resources