代码改变世界

天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  108 随笔 :: 0 文章 :: 3 评论 :: 23547 阅读
< 2025年4月 >
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 1 2 3
4 5 6 7 8 9 10

摘要

在Gitlab的作业日志中,执行PowerShell语句后的输出是乱码。即使是英文也是乱码。

网上搜索到的结果

下属两种做法,在Windows 11中都是无效的:

乱码的效果:

$ echo $MSBUILD

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\

$ cd $MSBUILD

$ msbuild.exe "Daiv_OA.Web\Daiv_OA.Web.csproj" -o $DAIV_OA_WEB_OUTPUT_DIR

msbuild.exe : �޷�����msbuild.exe����ʶ��Ϊ cmdlet���������ű��ļ��������г��������ơ����������Ƶ�ƴд����������·������ȷ��·����ȷ��Ȼ������һ�Ρ�

����λ�� ��:297 �ַ�: 1

+ msbuild.exe "Daiv_OA.Web\Daiv_OA.Web.csproj" -o $DAIV_OA_WEB_OUTPUT_D ...

+ ~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (msbuild.exe:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

1、在.gitlab-ci.yml中设置

build-job:
  stage: build
  tags: 
    - zhongfang-windows
  before_script:
    - chcp.com 65001  # 加入这一行
  script:
    - echo "Compiling the code..."

2、在Gitlab Runner的config.toml中设置

concurrent = 1
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "Alice-WIndows-11"
  url = "https://gitlab.********.cn"
  id = 37
  token = "****-************************"
  token_obtained_at = 2024-04-11T16:39:42Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  shell = "powershell"
  pre_clone_script = "chcp 65001"    # 加入这两行
  pre_build_script = "chcp 65001"
  [runners.cache]
    MaxUploadedArchiveSize = 0

正确做法

img

img

img

img

img

正确的输出

$ echo $MSBUILD

C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\

$ cd $MSBUILD

$ msbuild "Daiv_OA.Web\Daiv_OA.Web.csproj" -o $DAIV_OA_WEB_OUTPUT_DIR

msbuild : The term 'msbuild' is not recognized as the name of a cmdlet, function, script file, or

operable program. Check the spelling of the name, or if a path was included, verify that the path

is correct and try again.

At line:297 char:1

+ msbuild "Daiv_OA.Web\Daiv_OA.Web.csproj" -o $DAIV_OA_WEB_OUTPUT_DIR

+ ~~~~~~~

+ CategoryInfo : ObjectNotFound: (msbuild:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

继续去摸索下一个坑:这里明明有msbuild.exe,为什么就用不了呢?

posted on   终南山人  阅读(857)  评论(0)    收藏  举报
相关博文:
阅读排行:
· 精选 4 款免费且实用的数据库管理工具,程序员必备!
· 干货分享!MCP 实现原理,小白也能看懂
· Cursor:一个让程序员“失业”的AI代码搭子
· MCP开发应用,使用python部署sse模式
· 慢查询解决思路
点击右上角即可分享
微信分享提示