echo "======solution dircectory======";
ls;
echo "======building version======";
$versionDate=Get-Date -Format 'yyyyMMddHHmmss';
echo "v$versionDate";
$appPublishPath="H:devopsmemberportalv$versionDatepublish";
$iisSiteName="Default Web Site/memberportal/";
echo "======change api.config.ts======";
cd .srcappservicesapi-services;
Remove-Item ./api.config.ts -Recurse;
Rename-Item ./api.config.Staging.ts api.config.ts;
echo "======change success======";
echo "======begin restore packages======";
cd ../../../../;
npm install;
echo "======restore success======";
echo "======begin build code source======";
ng build --prod --aot --build-optimizer --extract-css --vendor-chunk=true --base-href ./ --output-path=$appPublishPath 2>$null;
echo "======build success======";
echo "======go to publish direcctory======";
pushd $appPublishPath;
pushd C:WINDOWSsystem32inetsrv;
echo "======change iis dir======";
./appcmd set vdir $iisSiteName -physicalPath:$appPublishPath;
echo "======change success======";
echo "======restart iis site======";
./appcmd stop site $iisSiteName;
./appcmd start site $iisSiteName;
echo "======restart success======";
echo "The Application is running......";