0

I am deploying a website using TFS i have a batch script that encrypts web.config file at the moment i have the id of the site hardcoded in.

QUESTION: How could i get the Website ID of the website that is being deployed and put it into the script #

I tried to pass in the application name but The encryption doesn't work. It needs the site id.

Also i can see the Site ID by calling the command

appcmd.exe list site SomeSite


%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pe "connectionStrings" -app "/" -site "2"
AutoTester213
  • 2,714
  • 2
  • 24
  • 48

1 Answers1

0

for anyone intrested i have solved it like this, I used applicationHost.Config file to search for the site name and assign the id that the site uses.

FOR /f "usebackqtokens=1-5delims=<=> " %%a IN ("%WinDir%\System32\Inetsrv\Config\applicationHost.Config") DO (
if "%%a"=="site" if "%%b"=="name" if "%%~c"=="SiteName" set siteid=%%~e
)
echo Website ID = %siteid%
pause
CALL %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pe "connectionStrings" -app "/" -site %siteid%
if %errorlevel% neq 0 exit /b %errorlevel%
pause
AutoTester213
  • 2,714
  • 2
  • 24
  • 48