运行 GitLab CI 作业时指定的任务可执行位置无效

Wee*_*ooo 5 continuous-integration continuous-delivery gitlab gitlab-ci .net-core

我正在尝试使用 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
Run Code Online (Sandbox Code Playgroud)

我正在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>
Run Code Online (Sandbox Code Playgroud)

git push origin cicd_test

我收到此错误 GitLab 作业控制台

/builds/username/project/Backend/Backend.csproj 的恢复在 58.11 毫秒内完成。
后端 -> /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/用户名/project/Backend/Backend.csproj]

构建失败。

据我所知,%ProgramW6432%是否有某种变量未设置?但我可以在哪里改变它呢?

值得注意的是,.gitlab-ci.yml如果我从 VS CLI 在本地运行它,则使用与中相同的命令进行部署可以正常工作

小智 -1

尝试从 Mac 发布到 Azure 应用程序服务时,我遇到了同样的错误。

这个问题帮助我解决了问题:https ://github.com/aspnet/websdk/issues/241

可以使用 msbuild 来完成,而不是使用“dotnetpublish”命令:

msbuild project-name.csproj -c Release /p:DeployOnBuild=true /p:PublishProfile=publishprofile.pubxml