我正在尝试使用GitLab CI为.NET Core应用程序设置CICD。
让我们从我的.gitlab-ci.yml
image : microsoft/dotnet:latest
before_script:
- 'cd Backend'
- 'dotnet restore'
build:
stage: build
script:
- 'dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=Properties/PublishProfiles/WebioProfile.pubxml'
only:
- cicd_test
然后WebioProfile
我正在使用
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://xxx.hostingasp.pl/</SiteUrlToLaunchAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>03120c29-ae98-4c30-9b8c-7ec70f6642fd</ProjectGuid>
<MSDeployServiceURL>ssl3.xxxx.hostingasp.pl</MSDeployServiceURL>
<DeployIisAppPath>xxxx.hostingasp.pl</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>user</UserName>
<Password>password</Password>
</PropertyGroup>
</Project>
git push origin cicd_test
我收到此错误GitLab作业控制台
还原在58.11毫秒内完成 /builds/username/project/Backend/Backend.csproj。
后端-> /builds/username/project/Backend/bin/Release/netcoreapp2.1/Backend.dll 后端-> /builds/username/project/Backend/obj/Release/netcoreapp2.1/PubTmp/Out/ /usr/share/dotnet/sdk/2.2.203/Sdks/Microsoft.NET.Sdk.Publish/build/netstandard1.0/PublishTargets/Microsoft.NET.Sdk.Publish.MSDeploy.targets(171,5): 错误MSB6004:指定的任务可执行文件位置 “%ProgramW6432%/ IIS / Microsoft Web Deploy V3 / msdeploy.exe”无效。 [/builds/username/project/Backend/Backend.csproj]构建失败。
据我所知,%ProgramW6432%
是某种未设置的变量?但是我可以在哪里更改呢?
值得注意的是,如果我从VS CLI在本地运行,则使用与.gitlab-ci.yml
中相同的命令进行部署可以很好地工作
答案 0 :(得分:0)
尝试从Mac发布到Azure应用服务时遇到相同的错误。
此问题帮助我解决了问题:https://github.com/aspnet/websdk/issues/241
可以使用msbuild来代替使用'dotnet publish'命令:
msbuild project-name.csproj -c Release /p:DeployOnBuild=true /p:PublishProfile=publishprofile.pubxml