代码之家  ›  专栏  ›  技术社区  ›  nikhil

使用适用于Windows的cmd shell在后台运行服务器

  •  0
  • nikhil  · 技术社区  · 1 年前

    我正试图在后台使用cmd shell运行一个名为CoreServer.exe的文件,如前所述 here 当我指定服务器的路径时,它告诉我,

    '.' is not recognized as an internal or external command,
    operable program or batch file.
    

    另一方面,如果我删除 shell: cmd 它运行良好。但在这种情况下,它使用Poweshell运行,我不希望这样,因为在Powershell中运行不是我想要的。

    这是我的工作流程文件。我在GitHub上的公共回购中也有这个 here

    name: Test unit tests CI
    
    on:
      push:
        branches: [ "main" ]
      pull_request:
        branches: [ "main" ]
    
      
    jobs:
      build:
    
        runs-on: windows-2022
    
        steps:
        - uses: actions/checkout@v3
    
        - name: setup Msbuild
          uses: microsoft/[email protected]
          
    
    #try nc -v -N 127.0.0.1 3334
     #curl http://localhost:3333 -I
     #vstest.console.exe ./Pico/Medman/FluidTransferTests/bin/Release/net481/FluidTransferTests.dll
    #Start CoreServer.exe in background
        
        - name: Start CoreServer.exe in the background
          shell: cmd
          run: ./Debug/CoreServer.exe -c -s &
    
        - name: Wait 7 seconds
          run: sleep 7
    
        - name: See status
          run: netstat -ntp
    

    为了添加更多信息,当我在本地的命令提示符下运行此CoreServer.exe时,它运行良好,并显示以下内容:,

    CoreServer.exe -c -s

    1 回复  |  直到 1 年前
        1
  •  1
  •   jessehouwing    1 年前

    windows shell不处理linux风格的路径分隔符。 ./debug 必须 .\debug ,将删除错误。

        - name: Start CoreServer.exe in the background
          shell: cmd
          run: .\Debug\CoreServer.exe -c -s &