简体   繁体   中英

How to Setup and Deploy a .net web app Build Using TFS 2015.Update3.RC1 CI on Prim

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:

  1. turn off IIS (iisreset -stop) via PowerShell.
  2. Move the built files to my iss location. In this example, it is C:\\inetpub\\apps\\My
  3. 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"
  4. 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

  1. 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

  1. Windows Machine File Copy this step is working correctly

  2. 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?

  1. How can I automatically Correct the web.config?

  2. 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)

  3. 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 (eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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