Set Application Pool for package using MSDeploy - iis-7

I am deploying a website using MSDeploy so using something like the below code.
"%ProgramFiles%\IIS\Microsoft Web Deploy\msdeploy.exe"
-verb:sync
-source:package=WebAppServer.zip
-dest:Auto
-setParamFile="was_params.xml"
-verbose
> webappserversync.log
Is there anyway to set the application pool ? I want to do this from the command line and not set it in a manifest or anything like that.
Shouldn't matter but this is in IIS7.

When you generate your package, you need to have an entry in the parameters.xml file for setting the Application Pool. When deploying, you either include a value for that in your setParameters.xml file, or use -setParam from the command line.
Here is the command I used to grab a site, which generated the proper parameters.xml file ...
msdeploy.exe
-verb:sync -source:appHostConfig="Default Web Site"
-enableLink:AppPoolExtension
-dest:package=site.zip
-declareParam:name="Application Pool",
defaultValue="Default Web Site",
description="Application pool for this site",
kind=DeploymentObjectAttribute,
scope=appHostConfig,
match="application/#applicationPool"
And to install this site from the command line, this ...
msdeploy.exe
-verb:sync
-dest:appHostConfig="MagicSite"
-enableLink:AppPoolExtension
-source:package=site.zip
-setParam:"Application Pool"="MagicPool"
Dig around in the parameters.xml file to see the entry necessary. And if you prefer, that -setParam entry can exist in your params.xml file instead.

Take a look at this answer:
Set application pool with MSDeploy and TFS 2010
Basically, you create a batch file with an adsutil script to set the app pool, and then you call MSDeploy to run that batch file on the target computer.

Related

Using DestinationVirtualDirectory in msdeploy to set Physical Path Location

This seems like it should be very straight forward but it is not working for me and I am out of ideas.
All I want to do is set the physical path when I deploy a package using msdeploy so that it doesn't go to the default inetpub\wwwroot location.
msdeploy -verb:sync -source:package="D:\PATH\TO\PACKAGE.zip" -dest:iisapp="Default Web Site/SiteName" -setParam:kind=DestinationVirtualDirectory,scope="Default Web Site/SiteName",value="C:\Program Files\Physical\Location"
I feel like I must be missing something obvious.
I've done this by adding an additional command (appcmd) to the MSDeploy package manifest to change the physical path of the IIS site during the deployment:
<runcommand path="%windir%\system32\inetsrv\appcmd set app /app.name:"Default Web Site/app12" /[path='/'].physicalPath:C:\temp\app12" waitInterval="5000"/>
http://www.dotnetcatch.com/2016/06/28/webdeploymsdeploy-quick-tip-change-iis-siteapp-physical-path-with-msdeploy/
The following changes the physical directory of a virtual application on a remote machine
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:apphostconfig="my-website-name\my-virtual-application-name",computername=my-computer-name,username=my-service-account-username,password=my-service-account-password -dest:package=template.zip -declareParam:name="destVirtualDir",kind=DestinationVirtualDirectory,scope="my-website-name",defaultValue="c:\my-default-folder-name"
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=template.zip -dest:apphostconfig="my-website-name/my-virtual-application-name",computername=my-computer-name,username=my-service-account-username,password=my-service-account-password -setParam:name="destVirtualDir",value="c:\my-new-folder-name"
To make sure no copying of source and target occurs you can add
-enableRule:Donotdeleterule -skip:objectName=filepath,absolutePath=.*
The above was 'inspired' by https://forums.iis.net/t/1169416.aspx which also shows how to make other website and virtual app changes

msdeploy delete ASP.NET Temporary files

I am using msdeploy to delete web sites using this command
msdeploy -verb:delete -dest:apphostconfig="Default Web Site/FOO",computerName="BAR"
however this does not delete the files under
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\FOO
Is there an argument for msdeploy to delete these files too?
If that is not the case, is there something else I can use in a Power Shell or batch script from a remote computer?
You can use the runCommand MSDeploy provider:
msdeploy.exe -verb:sync -source:runCommand="net start MyService" -dest:auto
https://technet.microsoft.com/en-us/library/ee619740(v=ws.10).aspx

How to change asp .net web service application build path instead of bin folder?

I am working asp.net web service application.
Normally running time my application dll taken from bin directory.
now i want to add some XML file and folder,so i want to change web service build directory.
I changed directory like this [ex:bin\Common],but this kind of issue came.
Parser Error
Parser Error Message:** Could not create type 'WebService.MainLogic'.
Source Error:
Line 1: <%# WebService Language="C#" CodeBehind="MainLogic.asmx.cs" Class="WebService.MainLogic" %>
Source File: /MainLogic.asmx Line: 1
How can I change the directory?
you can copy bin folder to specific folder after build project.
Right Click on project and go to properties => Build Events
in Post-build event command line write below command :
xcopy /Q /Y "$(TargetPath)" "C:\path\to\somewhere\"
for more information see this link : Copy bin files on to Physical file location on Post Build event in VS2010

Nested Virtual Directory Deleted on msdeploy

The project I have uses msdeploy to publish a package to IIS. It deploys over an existing version of the project. within the web application, I have a virtual directory, but every time I deploy the project, the virtual directory disappears.
I am calling MSDepoly in the following manner:
-source:package='d:\[...]\9.1.0.67\application\AppName.zip' -dest:auto,computerName="hostSite.com",userName="AutoInstall",password="****",authtype="NTLM",includeAcls="False" -verb:sync -enableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"d:\...\9.1.0.67\application\AppName.SetParameters.xml" -skip:objectName=binding -skip:absolutePath="info$" -skip:objectName=dirPath,absolutePath="help$",skipAction=Delete
as you can see at the end, I have the following skip rules:
-skip:objectName=binding -skip:absolutePath="info$" -skip:objectName=dirPath,absolutePath="help$",skipAction=Delete
The binding skip rule is working, but the virtual directory, info, is still getting removed from the web application. the virtual directory is nested within the help directory, so I added the skip action to skip deleting that folder as well.
I based all of this information from the following blog article, but my virtual directory, info, is still getting removed on deployment.
Please help!
I encountered the same issue. In development it appears the following skip rule prevented the Virtual Directory from being removed by MSDeploy.
-skip:ObjectName=virtualDirectory,absolutePath=.*NameOfVirtualDirectory
I gave up on getting msdeploy to play nice. I just wrote a bat script that would be executed after msdeploy completed:
mkdir C:\inetpub\application_wwwroot\VirtualDirectoryPhysicalDir
ECHO adding read permissions to the app pool
cacls C:\inetpub\application_wwwroot\VirtualDirectoryPhysicalDir/t /e /g "IIS APPPOOL\MyAppPool":r
ECHO creating "info" virtual directory
C:\Windows\System32\inetsrv\appcmd add vdir /app.name:"WebApplication/AppVirtualDirectory" / /path:"/help/info" /physicalPath:"C:\inetpub\application_wwwroot\VirtualDirectoryPhysicalDir"
C:\Windows\System32\inetsrv\appcmd set vdir /vdir.name:"Medrio/MedrioWeb/help/info" /physicalPath:"C:\inetpub\application_wwwroot\VirtualDirectoryPhysicalDir"

How to stop/start IIS 7 application through command line?

I would like to create a batch file to start one IIS application, and stop another one.
How it can be done using command line?
How to combined it in batch file?
http://www.windowsnetworking.com/articles_tutorials/Configuring-IIS-7-command-line-Appcmdexe-Part1.html
Put this into a file with .bat extension.
#echo off
appcmd start sites "site1"
appcmd stop sites "site2"
Update
Just ensure that appcmd is available anywhere by adding %windir%\system32\inetsrv\ to the PATH environment variable of your system. Alternatively, you can use the full path to appcmd.exe in the batch file.

Resources