I have a question about how to deploy website and its referenced web services from Dev environment to production environment by using some easy method.
Our deploy structure is basically like Desktop->Dev Server->Production Server.
Now, I create a web service (just named MailingServices for example), I deploy it Dev Server, the URL link should like: http://192.168.3.17:90/MailingServices.asmx
and then I deploy it to production server where link is probably like http://202.70.115.114:90/MailingServices.asmx
Now I create one asp.net website to consume this mailing services.
I create this website in my desktop computer, and add a reference to MailingServices Dev link which is http://192.168.3.17:90/MailingServices.asmx, and then I check in the website to its dev environment, this stage is fine: Website Dev reference Web Services Dev.
But If deploy this website into its production server, how can I change the url link of that web services from its dev link to live link?
I currently know that when the website is deployed to production server, you can over-write the link in web.config file of website, but asp.net generates some other XML files when it add a web service reference, well I can over-write these xml files too.
However, I think this not an easy and appropriate way to complete this whole task, So I come to ask if you guys have anyone suggestion about this?
Many Thanks.
Edited
Development Environment:
Server: windows 2008
Web: ASP.NET 3.5/4.0, IIS6.0+
Source Control: VSS 2005, we do not have Automation Build & Continuous Integration
If you need to transform your web.config on deploy then I would suggest that you take a look at web.config transformations. With these transformations when you publish from inside of VS the transformations will be automatically run for you, but since it looks like you are not deploying from VS you will need to perform some work to streamline the process. Here is what you need to do conceptually:
Build your project
Prepare your site for deployment
Transform the web.config file
Publish your site
For step #3 you can use the TransformXml task that we ship with VS (when you select Web to be installed). Using this task is very easy, here is a sample project which demonstrates this.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="TransformWebConfig">
<TransformXml Source="some\path\to\the\source\web.config"
Transform="some\path\to\the\web.transform.config"
Destination="some\path\to\the\dest\web.config" />
</Target>
</Project>
I've got a bunch of info on using this task on my blog at http://sedodream.com/SearchView.aspx?q=TransformXml.
Related
Using Visual Studio 2015 update 3
and Team Foundation server Update 3 (on-site)
I'm attempting to setup up and auto deploy for a .net core boilerplate app targeting full framework 4.61. Currently my app is mostly the stock app you get when selecting new->Project->Templates->Visual C#->Web->ASP.NET Core Web Application(.Net Framework). My Goal is to Push via Git and then have the website show up correctly on the test server.
I was able to use the instructions I found at the MVA
However, they did not go into any detail on how to deploy to an on-prem server. But they clearly stated that it was possible.
I have Setup this web project in TFS2015 using Git as source control. For my Build Definition I'M using the Visual Studio default build ScreenShot of TFS build Definition, I also have the site building whenever I push new code.
The problem I have is I don't understand what to do next.
my thought is that I would need to:
turn off IIS (iisreset -stop) via PowerShell.
Move the built files to my iss location. In this example, it is C:\inetpub\apps\My
run scripts to update database schema(note currently there is no database setup but that is my next step. planning to use "code first" with "Entity Framework"
I would have to turn IIS back on.
I did get a big clue to add the following in my Visual Studio Build Step. MSBuild Arguments.
/p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish
/p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True
/p:publishUrl=$(build.artifactstagingdirectory)\for-deploy\website
From Benjamin Day Blog www.benday.com/2016/09/08/an-asp-net-mvc-site-thats-easy-to-deploy-from-a-tfs-build/ (sorry can't link due to lack of rep points)
using those build MS build arguments I can find my built website and it appears to be working correctly except for the Web.config file is showing
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
When is should be
<aspNetCore processPath=".\My.Multnomah.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
My Release Definition is in three steps
PowerShell on Target Machines
Machines = the server I'm going to deploy to
Admin Login = My AD username.(will switch to service account after working)
Protocol = Https
PowerShell Script = file location on the Script I have on the agent PC/which is also the test web server
here is the PowerShell script to turn of IIS.
iisreset -stop
Windows Machine File Copy
this step is working correctly
PowerShell on Target Machines
same as step 1. but
Currently, the Release is working if I manually turn off IIS then manually update the web.config file.
So, in short here are the questions?
How can I automatically Correct the web.config?
How can I arrange to have IIS Stopped before the file transfer and Started after the Transfer or is there a better way?(Current the release is failing if I don't have IIS off)
Is my understanding how I explained this correct/ What are the Build steps you would use to deploy on-prem?
1.How can I automatically Correct the web.config?
You can replace corresponding values with variable values (Open your build definition=>Variable) by using Replace Token task.
For example: Add variables to your build/release definition (e.g. name:LAUNCHER_PATH value:.\My.Multnomah.exe), change your web.config (replace %LAUNCHER_PATH% to #{LAUNCHER_PATH}# and others)
2.How can I arrange to have IIS Stopped before the file transfer and Started after the Transfer or is there a better way?
You don’t need to stop IIS before update web.config file, you can update it directly. After updating web.config, the website will be recycled automatically.
3.Is my understanding how I explained this correct/ What are the Build steps you would use to deploy on-prem?
These steps are ok, there are IIS Web App Deployment Using WinRM and IIS Utilities task that can help you to deal with IIS.
For a long time I have been performing dated deploys to our IIS servers, basically this means that each deploy gets its own dated folder within the web site folder (c:\sites\my-site\20140824-1236 for example). I then redirect the web app to the new deployment folder.
This gives us a quick role back capability if things go pear shaped.
The problem is that we are looking at moving deployment over to the new web deploy techniques, while we have been using the new techniques within QA and UAT for a while - the standard behaviour is to simply replace the files at the location defined within the IIS web site.
Before I go and start looking at remote PowerShell to re-configure IIS before executing the web deploy.. does anyone know how I can achieve this using standard web deploy.. maybe with msbuild extensions or something?
How about using the automatic backup capabilities in Web Deploy v3?
http://www.iis.net/learn/publish/using-web-deploy/web-deploy-automatic-backups
i am looking for a way to autodeploy a Dot Net Nuke website by TFS after checking in. I also need to some how transform web config to the right connection for the deploy server.
Since this is a website but not a web application, thing becomes tricky. If you have done it before, please give me some idea.
Thanks
I have not done auto deployment with TFS but did automate the process with SVN. What we did is simply have the script deploy everything that had changed since last login to the web server - EXCEPT - the web.config.
Database scripts were handled by a process like this but those were not as reliable as the SVN code deployment was.
HTH
You could use a deployment tool such as kwatee (self promotion). Kwatee is configured via a web GUI and can then deploy any application or site via python scripts and transform files along the way.
You can use Visual Studio web deploy feature. ALM Rangers shipped a ready to use BRDLite Reference template for this purpose which you can download here. Also, check this link for documentation for the template usage.
If you're using VS2010, you can use a Web Deploy Project in your solution. TFS will talk to the WDP as it would with a web application's project file.
For config transforms, you can use a tool called SlowCheetah.
I would like to use web.config transformation but do not see the "Add Config Transforms" in the context menu when i right-click on my original web.config file.
I do not have a Web Application Project and cannot have one. My solution has a few projects for BLL, DAL etc, then i have a local IIS website for the main Website.
Under my local IIS website i have a web.config and have tried to add a web.Debug.config like such:
How can i do web.config transformation using the localhost IIS website and not having to creating a Web Application Project? Is it even possible? Is creating a Web Application Project a requirement?
I was recently reading up on this subject and to my knowledge you can not do web.config transformation in a Web Site project for one simple reason – Web Sites don’t have project files, which is where the msbuild configurations are stored. So if you need that functionality you will have to create a project file. But have a look at this blog which I think gives a better explanation for this.
http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/
Having said that if you do find out that im wrong, which i might be please keep me updated with what was your solution
Thanks
I am researching a new ASP.Net project that we would like to host in a Windows Azure Web Role.
One of the technical requirements of this project is to make use of the full pre-compilation options (non-updatable, single page assembly) of the ASP.Net Web Site project model - as opposed to the ASP.Net Web Application project model.
Is it possible to host ASP.Net Web Site projects in Azure? Best I can tell the project templates for Azure are ASP.Net Web Applications only at the moment.
Okay, I was struggling with the same problem for couple of days, here is the step-by-step guide
(1) Publish your website project to a folder (for my case is "PrecompiledWeb\WebSite1", which resides in the sub folder of my azure project)
(2) Modify your service definition(.csdef), adding a webrole
<WebRole name="WebSite1" enableNativeCodeExecution="true">
<InputEndpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</InputEndpoints>
<ConfigurationSettings />
</WebRole>
(3) Run the following command(CSPack) at command prompt
cspack
CloudService1\ServiceDefinition.csdef
/role:WebRole4;WebRole4
/role:WorkerRole1;WorkerRole1\bin\Debug;WorkerRole1.dll
/role:WebSite1;PrecompiledWeb\WebSite1
/out:CloudService1.cspkg
/generateConfigurationFile:"ServiceConfig.cscfg"
(4) Basically you are almost done!
Good luck! ;)
The short answer is yes, but it isn't easy.
One of the cool things about Azure is that almost anything copy-deployable can be deployed to Azure. As such you web site project can be deployed. The difficult part is that the Visual Studio tools don't currently (and may not ever) support it. You'll need to use the CSPack command line tool to package your deployment.