注意,IIS路径一定要用 ,不能用
/
https://blog.csdn.net/aixian3620/article/details/102205138
echo "======solution dircectory======";
ls;
echo "======building version======";
$versionDate=Get-Date -Format 'yyyyMMddHHmmss';
echo "v$versionDate";
$iisSiteName="hoawebapis";
$sourceBuildPath="H:devopshoawebapiv$versionDateuild";
$sourcePublishPath="H:devopshoawebapiv$versionDatepublish";
echo "======begin restore packages======";
dotnet restore "Hoa.Web.Host/Hoa.Web.Host.csproj" -s "https://api.nuget.org/v3/index.json" -s "https://www.myget.org/F/miniprofiler/api/v3/index.json";
echo "======restore success======";
echo "======begin build code source======";
dotnet build "Hoa.Web.Host/Hoa.Web.Host.csproj" -c Release -o $sourceBuildPath;
echo "======build success======";
echo "======begin publish code source======";
dotnet publish "Hoa.Web.Host/Hoa.Web.Host.csproj" -c Release -o $sourcePublishPath;
echo "======publish success======";
echo "======begin set asp.net core environment======";
[Environment]::SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Staging", "Machine")
echo "======set success======";
echo "======go to publish direcctory======";
pushd $sourcePublishPath;
echo "======change appsetting.json======";
Remove-Item ./appsettings.json -Recurse;
Rename-Item ./appsettings.Staging.json appsettings.json;
echo "======change success======";
pushd C:WINDOWSsystem32inetsrv;
echo "======change iis dir======";
./appcmd set vdir "$iisSiteName/" -physicalPath:$sourcePublishPath;
echo "======change success======";
echo "======restart iis site======";
./appcmd stop site $iisSiteName;
./appcmd start site $iisSiteName;
echo "======restart success======";
echo "The Application is running......";