How to get siteroot path in Azure launch task instead of matching?

I have an Azure web project that configured a launch task in ServiceDefinition.csdef.

<Startup>
  <Task commandLine="Task.cmd" executionContext="elevated" taskType="simple" />
</Startup>

In Task.cmd, I have code that needs a web project path. Something like that:

InstallService.exe /webpath="%cd%"

but the directory in the launch job is different from the real production path. (E: \ approot vs E: \ siteroot \ 0).

Is there a way to get the production path in my Task.cmd?

thank

+4
source share
1 answer

You will use the litle bit of PowerShell! You have to create one PowerShell script and change your cmd. Your entire PowerShell file (startup.ps1) should look something like this:

Import-Module WebAdministration
$site = Get-ChildItem IIS:\Sites | Where-Object {$_.State -eq 'Started'}
$siteRoot = $site.PhysicalPAth
$fileExe = "InstallService.exe"
& $fileExe  /webpath=$siteRoot

, , . startup.cmd :

@echo off 
powershell -command "Set-ExecutionPolicy Unrestricted" 2>> err.out  
powershell .\startup.ps1 2>> err.out

, .

+1

Source: https://habr.com/ru/post/1529000/


All Articles