我正在尝试使用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.2.203/sdks/microsoft.net.sdk.publish/build/build/netstandard1.0/publishtargets/microsoft.net.net.net.sdk.publish.publish.msdeploy.targets: 错误MSB6004:指定的任务可执行位置 "%programw6432%/iis/microsoft Web部署v3/msdeploy.exe"无效。 [/builds/username/project/backend/backend.csproj]构建失败。
从我所看到的,%ProgramW6432%
是某种未设置的变量?但是我在哪里可以更改它?
值得注意的是,如果我从vs vs cli
.gitlab-ci.yml
中相同的命令部署尝试从Mac发布到Azure App Service时遇到了相同的错误。
这个问题帮助我解决了问题:https://github.com/aspnet/websdk/issues/241
而不是使用" dotnet Publish"命令,可以使用msbuild完成:
msbuild project-name.csproj -c Release /p:DeployOnBuild=true /p:PublishProfile=publishprofile.pubxml