I'm using MSBuild to build and deploy the website, Before deploying i need to recycle the Application Pool, How can i do this from msbuild script?
(I do not want to restart the IIS just recycle the application pool)
Why don't you use the extension pack:
http://www.msbuildextensionpack.com/help/4.0.4.0/index.html
It has a task:
<MSBuild.ExtensionPack.Web.Iis7AppPool TaskAction="Recycle" Name="MyAppP"/>
That should do what you ask.
The command is
c:\Windows\system32\inetsrv\appcmd.exe recycle apppool "MyAppPool"
You can execute it within msbuild target using <Exec> task.
Related
We currently use Octopus Deploy to push web sites to IIS servers hosted on Window Server 2012.
We wish to ditch Octopus and use our on-premises TFS 2017's inbuilt release system instead. We have build definitions that publish artifacts (the web site binaries & content) ready made .
With Octopus we have tentacles installed on all the servers.
The legacy release process defined in Octopus is like so:
Set up IIS (Powershell script to configure app pools for a site, map virtual directory to absolute path)
Deploy nuget package (package contains web site binaries & scripts) - unpacks package containing web site to the physical path of the associated virtual directory
Enable Windows Authentication (one-line powershell script that calls Set-WebConfigurationProperty)
Disable Anon Auth (powershell again.)
I'm not keen on the amount of Powershell used in our Octopus process, and would like to minimise Powershell in the TFS release definition.
My question is: what is the Microsoft recommended way of deploying ASP.NET web sites (vanilla MVC projects, not .NET core) to servers in a CI environment? Is it possible to configure the sites authentication at the same time?
NB:
I took a look at the OOB IIS publishing WinRM deployment tasks and I fear they may require more time than our infrastructure team has (to configure firewalls etc.)
We have Visual Studio 2017 installed on the build server.
TIA,
Scott
According to your description you are deploying on a Web site hosted on IIS.
First through TFS build you could use some msbuild arguments such as /p:DeployOnBuild=True /p:SkipInvalidConfigurations=true /p:WebPublishMethod=Package /p:PackageLocation=$(Build.ArtifactStagingDirectory) /p:PackageAsSingleFile=true to generate a package.
Then in release definition use Deploy: Windows Machine File Copy task - Copy the Web Deploy package to the IIS servers. Finally use Deploy: WinRM - IIS Web App Deployment - Deploy the package. This task running on the Build and Release agent opens a WinRM connection to each IIS server to run Powershell scripts remotely in order to deploy the Web Deploy package.
For more detail/step to step tutorial, you could reference below tutorials, even some are the samples for web app:
End to End Walkthrough: Deploying Web Applications Using Team Build
and Release Management
An ASP.NET MVC Site That’s Easy to Deploy from a TFS Build
Working with Web Deploy and Release Management
Using the IIS WinRM tasks would probably the best and easiest way to do it. You can find some good guidance of how to configure things.
The basics that you need in place are:
Make sure that WinRM is configured on the target server and that your agent can connect to them
Package your web site by adding these msbuild parameters when you compile the project
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.ArtifactStagingDirectory)
Before the start of debugging for my MVC application, I want to recycle the IIS app pool it is using. I can't find any type of script I could create or setting I could change from online searches.
Does anyone know a way to recycle the assigned app pool when I start the debug process in .NET?
If you want to restart the whole IIS,just issue iisreset command.Or You can write a simple Powershell script to do this
Import-Module WebAdministration
$mysite = "Default Web Site"
$pool = (Get-Item "IIS:\Sites\$mysite"| Select-Object applicationPool).applicationPool
Restart-WebAppPool $pool
We are deploying our new .NET Core Wep Api through TeamCity and Octopus, it runs on Kestrel behind IIS. Everything is fine except that the first request takes about 2 minutes. That is, the first request after deploy and the first request after restarting the site on IIS.
To publish the app we use
dnvm use 1.0.0-rc1-update1 -a x64
dnu publish --configuration release --runtime active --no-source --include-symbols
Older apps on the same IIS Instance take about 15sec to respond to the first request.
Our .NET Core app responds after about 15 seconds when running it purely on Kestrel from the same actual code that is deployed to IIS.
What is happening for the remaining 1m45s - why is it taking so long?
How can we go about to debug this?
Update:
As it turns out, IIS is unable to shut down the Kestrel process (dnx.exe) gracefully. It crashes with the following error:
Unhandled exception at 0x00000000776E298A (ntdll.dll) in w3wp.exe: 0xC000070A: Status 0x (parameters: 0xFFFFFFFFC0000008, 0x0000000000000324, 0x000000000167D930, 0x0000000000277520, 0x000007FEE60388F4).
If I terminate the dnx.exe process manually and then restart the site it starts up quite fast, so my theory is that the Octopus deploy step somehow encounters the same exception and IIS has to wait for the host process to time out before it spawns a new working process.
How can I make IIS shut down the dnx process gracefully? How can I get a more understandable exception from IIS?
The cause of the problem was that IIS was unable to gracefully stop the dnx process running Kestrel, and had to wait for it to timeout in order to get a working one running.
To work around this we added a PowerShell script to stop the dnx process manually as the first step of the Octopus Deploy process:
Stop-Process -processname dnx -ErrorAction SilentlyContinue -Force
As to why IIS is unable to gracefully terminate the worker process and how to fix that I still have no idea.
I'm writing an ASP.NET 5 application targetting .Net Core using EF7. When I'm done, I'd like to publish the application to a platform-specific installer that, when run, will install a service, deploy a database based on user-input credentials for a SQL Server. The service will self-host the ASP.NET application.
Is this possible? How would I go about achieving this?
Thanks!
We use MSDeploy at work to deploy all of our components: web applications, windows services, scheduled task, SQL databases, etc.
You could use the following command to package up the service code:
msdeploy -verb:sync -source:dirPath=/path/to/service -dest:package=servicePackage.zip -verbose
And this command to deploy it to the target:
msdeploy -verb:sync -source:package=/path/to/service -dest:package=servicePackage.zip -verbose
Use a database project for the SQL database and create a DacPac to publish. You can use MSDeploy to publish the DacPac:
MSDeploy –verb: MSDeploy-verb –source:dbSqlPackage="db.dacpac"[,dbSqlPackage-source-parameters] –dest:dpSqlPackage="TargetConnectionString"[,dbSqlPackage-target-parameters]
Finally use Manifests to wrap it all up into a single MSDeploy package.
Regarding the user input values for the database, I would use WebDeploy Parameterization files to define the variables and apply them to the database deployment. These parameterization files can be used for non-web deployments via MSDeploy. Then write some PowerShell to wrap the MSDeploy command for deployment to prompt the user for their inputs and edit the SetParameters file.
I have to debug a WCF hosted in local IIS. Each time I have to attach two processes "w3wp.exe".
One ID is 7624, the other is 8372.
Users: one is "IIS APPPOOL\ASP.NET V4.0 Integrated[administrator]
the other one is "IIS APOOL DefaultAppPool[administrator]
Questions:
What they are? (google search but bo clue)
Can I just attach one process rather all?
Thanks
Updated:
See IIS image:
Just check in your IIS Management Console the Application Pool in which your site resides, then attach to the proper one. Probably, as you're using WCF, you're running under .NET 4, so under the first process you linked.
Application pool is the set of apps that run under same worker process.
Important thing in practice is that one app pool can serve only applications with same version of .NET (version of .NET CLR - to be precise). It is also good to remember that applications from the same app pool will "share" recycling of worker process.
So, you should look up at the IIS in which app pool your service is running and debug only process associated with this app pool.
They are Application Pool Identities. This is the newer (and securer) way of assigning priveleges to websites. Essentially a site runs on its own application pool, so you assign rights to files based on that pool.
See: http://www.iis.net/learn/manage/configuring-security/application-pool-identities