MSBUILD发布错误\u用户\u未经授权 总结
我正在Windows Server 2016上使用9.2.0 Gitlab的CI multirunner。在通过MSBUILD发布ASP.NET项目的步骤中,我从IIS收到一个身份验证错误MSBUILD发布错误\u用户\u未经授权 总结,msbuild,gitlab,publish,gitlab-ci,continuous-delivery,Msbuild,Gitlab,Publish,Gitlab Ci,Continuous Delivery,我正在Windows Server 2016上使用9.2.0 Gitlab的CI multirunner。在通过MSBUILD发布ASP.NET项目的步骤中,我从IIS收到一个身份验证错误error\u USER\u UNAUTHORIZED。但是,当我在构建机器上使用CMD窗口时,我运行相同的发布命令-所有内容都已发布。无论我使用的是系统还是管理员帐户 复制步骤 安装IIS发布 安装Gitlab的构建代理 创建Gitlab的YAML构建脚本(见下文) 运行构建 实际行为 在发布步骤中,我遇到了
error\u USER\u UNAUTHORIZED
。但是,当我在构建机器上使用CMD
窗口时,我运行相同的发布命令-所有内容都已发布。无论我使用的是系统
还是管理员
帐户
复制步骤
错误\u用户\u未经授权的错误
预期行为
在发布步骤中,我已将ASP.NET发布到服务器
相关日志和/或屏幕截图
环境描述
我正在windows 2016上使用共享运行程序(gitlab-ci-multi-Runner-windows-386,版本9.2.0)。MSBUILD是Microsoft Visual Studio 2017的一部分
YAML脚本
通过更改MSBUILD的参数顺序和格式来解决
- '"%msbuild%" "%solution%" /p:DeployOnBuild=True;Username=username;Password=password;DeployTarget=MSDeployPublish;MsDeployServiceUrl=https://192.168.1.66:8172/msdeploy.axd;Configuration=Release;TargetFramework=v4.5.2;AllowUntrustedCertificate=True;DeployIisAppPath=Faso;MSDeployPublishMethod=WMSVC;SkipExtraFilesOnServer=True;ExcludeFilesFromDeployment="Web.config;ConnectionStrings.config;system.config"'
在做了大量的修改后(发布在IDE中有效,但不是命令行),我复制粘贴了您的命令,替换了参数,它就起作用了。@nurettin另一个问题是我的密码。它包含一个感叹号(!),CMD没有正确翻译它,并破坏了命令。我还有一个带感叹号的密码,但它没有破坏命令行(我不使用powershell或bash)。尽管我知道,由于过去使用bash的经验,密码字符可能会破坏命令。
variables:
solution: Sources\Faso.sln
msbuild: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
nunit: C:\NUnit\NUnit.Framework-3.7.0\bin\net-4.5\nunitlite-runner.exe
nuget: C:\NuGet\nuget.exe
before_script:
- echo Setting encoding...
- echo %solution%
- echo Restoring NuGet packages...
- '"%nuget%" restore "%solution%"'
stages:
- build-test
- deploy-5023
build-test:
stage: build-test
script:
- chcp 65001
- echo Building...
- '"%msbuild%" "%solution%" /t:Build /p:Configuration=Release /p:TargetFramework=v4.5.2'
- echo Testing...
- dir /s /b *.Tests.dll | findstr /r Tests\\*\\bin\\ > testcontainers.txt
- 'for /f %%f in (testcontainers.txt) do "%nunit%" "%%f"'
except:
- tags
deploy-5023:
stage: deploy-5023
script:
- chcp 65001
- echo Deploying...
- '"%msbuild%" "%solution%" /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:MsDeployServiceUrl=https://192.168.1.66:8172/msdeploy.axd /p:username=user /p:password=password /p:Configuration=Release /p:TargetFramework=v4.5.2 /p:AllowUntrustedCertificate=True /p:DeployIisAppPath=Faso /p:MSDeployPublishMethod=WMSVC /p:SkipExtraFilesOnServer=True /p:ExcludeFilesFromDeployment="Web.config;ConnectionStrings.config;system.config"'
when: manual
except:
- tags
artifacts:
expire_in: 1 week
paths:
- Sources\Mvc\App_Data\
- Sources\Mvc\bin\
- Sources\Mvc\Content\
- Sources\Mvc\favicon.ico
- Sources\Mvc\Global.asax
- Sources\Mvc\Web.config
- '"%msbuild%" "%solution%" /p:DeployOnBuild=True;Username=username;Password=password;DeployTarget=MSDeployPublish;MsDeployServiceUrl=https://192.168.1.66:8172/msdeploy.axd;Configuration=Release;TargetFramework=v4.5.2;AllowUntrustedCertificate=True;DeployIisAppPath=Faso;MSDeployPublishMethod=WMSVC;SkipExtraFilesOnServer=True;ExcludeFilesFromDeployment="Web.config;ConnectionStrings.config;system.config"'