Jenkins + PowerShell + .net core 自动打包
注意,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:\devops\hoawebapi\v$versionDate\build";
$sourcePublishPath="H:\devops\hoawebapi\v$versionDate\publish";
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:\WINDOWS\system32\inetsrv;
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......";
如果您觉得本文对你有用,不妨帮忙点个赞,或者在评论里给我一句赞美,小小成就都是今后继续为大家编写优质文章的动力,百小僧拜谢!
欢迎您持续关注我的博客:)
版权所有,欢迎保留原文链接进行转载:)