Using DestinationVirtualDirectory in msdeploy to set Physical Path Location - msdeploy

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

Related

Visual Studio looks for dll in the wrong directory

I am getting an error of "Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies" in the browser of my asp.net app. Microsoft.AI.Web is from Microsoft.ApplicationInsights.Web NuGet package.
I noticed this:
LOG: Appbase = file:///D:/Source/Workspaces/AppName/Branches/Main/Application/WT/
LOG: Initial PrivatePath = D:\Source\Workspaces\AppName\Branches\Main\Application\WT\bin
the dll in question is located at D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll
As for personal dll's -- In the project-->properties-->build-->output path--> I have it set as "..\Any\Debug\". When I build the project the DLL's populate there.
I checked References and code in .csproj file and all the dll are located where I specified to.
I am not sure why it's trying to look at the bin file of the project when I told the output is somewhere else AND to look for the dlls in that same folder(through references and .csproj file). How do I make it so that VS will look for the dlls in the folder path I want instead of "WT\bin"?
When I change my project output path to "bin", it can detect the dll's there EVEN though the path of the dll remains the same( D:\Source\Workspaces\AppName\Branches\Main\Application\packages\Microsoft.ApplicationInsights.Web.2.4.1\lib\net45\Microsoft.AI.Web.dll).
Since it's a Microsoft strong signed DLL, add it to the server's GAC.
If you place it in the GAC, it'll find the file automatically. Another plus there is that if you need it for another project deployed on the same server, you don't need to deploy it again.
Here's some information on how to install a DLL into the GAC on the server machine, assuming gacutil is not installed there. Look at the accepted answer, not the question.
Drag and drop a DLL to the GAC ("assembly") in windows server 2008 .net 4.0
Copy gacutil.exe and gacutil.exe config from your machine to the server's C:\Windows\Microsoft.NET\Framework\v4.0.30319
Then run on the server:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\gacutil.exe" /i "PATH TO YOUR DLL"

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

Why aspnet_compiler requires virtual path (-v) parameter?

I want to prepare a pre-compiled package of ASP.NET MVC 4 site.
I can precompile it using commandline as follows:
aspnet_compiler -nologo -v / -p "C:\WebSite1" -u "C:\TargetPath"
However it baffles me, why aspnet_compiler requires virtual path. What if I decide later on to deploy this package to an IIS server under different path? Could it cause some run-time problems?
By deployment I mean here simple xcopy deployment.
If you specifiy the physical path of the source with the -p switch, then the virtual path is required. I reluctantly submit this page http://www.asp.net/web-forms/tutorials/deployment/deploying-web-site-projects/precompiling-your-website-cs for some info on how the -v can play in with app relative references ie ~/path/file. What he says needs more qualification and does not appear to apply to apps under the default IIS site.
His explanation is that using -v /MySite will change references from ~/path/file to ~/MySite/path/file. However I have not experienced this behaviour. Atleast as far as compiling apps that are under the default IIS website (regardless of being on the root of the site or nested). If I compile with for instance /v kart, inline references and codebehind references to "~/path/file" arrive in the dll as "~/path/file", not "~/kart/path/file". I have had no runtime problems deploying my WebForm apps elsewhere where the app root is now at a different path.
If you are compiling apps that are under the default IIS website, it is redundant to use -p with the physical path to the source and -v with the virtual path. If you omit the -p switch it will compile the same as only using the -v. Being redundant with the -p and physical source path may be nice when reviewing a batch file to have the source location documented.

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"

Set Application Pool for package using MSDeploy

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.

Resources