提问人:dharani kumar 提问时间:11/18/2023 更新时间:11/18/2023 访问量:36
Nuget restore myapp.sln 未被识别为 Gitlab CI/CD 中用于 Web 窗体应用的命令 ASP.NET
Nuget restore myapp.sln is not being recognized as a command in Gitlab CI/CD for ASP.NET Web forms app
问:
我正在尝试为我的 ASP.NET Web 窗体应用程序设置 CI/CD。我需要在Gitlab中完成。所以我做了很多研究,并在 Gitlab 上使用了 dotnet CI 的模板。 这些是我使用脚本的一些来源。
https://stackoverflow.com/a/38211190
https://medium.com/@gabriel.faraday.barros/gitlab-ci-cd-with-net-framework-39220808b18f
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/dotNET.gitlab-ci.yml
以下是我gitlab-ci.yml中的脚本
variables:
GIT_STRATEGY: none
NUGET_PATH: 'C:\Nuget\nuget.exe'
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe'
stages:
- build
- deploy
# before_script:
# - $NUGET_PATH restore ..MyApp\MyApp.sln
build-job:
stage: build
tags:
- myapp-dev
script:
- cd c:\dharani\git\MyApp
- '& "$NUGET_PATH" restore ..\MyApp\MyApp.sln'
- '& "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe" /p:Configuration=Debug /clp:ErrorsOnly ..\MyApp\MyApp.sln'
artifacts:
expire_in: 2 days
paths:
- '.\bin\Release\Publish\'
但是,我无法运行 nuget restore 命令。它给出以下错误-
$ & "C:\Nuget\nuget.exe" restore "..\MyApp\MyApp.sln"
& : The term 'C:\Nuget\nuget.exe' 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 C:\Windows\TEMP\build_script2722061214\script.ps1:235 char:3
我已将最新的 nuget 可执行文件下载到我的本地,并根据来源使用本地 nuget 和 MSbuild 路径。我是 CI/CD 的新手,我什至不确定如何调试问题。我直接在命令中使用了路径而不是变量,删除/添加了引号和所有其他语法,但仍然无法让它工作。没有 restore 命令并且只在 sln 文件上运行 MS 构建,我得到
C:\dharani\git\MyApp\MyApp\Services\Service.cs(13,7): error CS0246: The type or namespace name 'AuthorizeNet' could not be found (are you missing a using directive or an assembly reference?)
所以我认为恢复nuget包应该可以解决这个问题。我已经用不同的语法运行了多次,并且还为环境变量添加了 nuget 路径(不确定这是否是解决方案)
基本上,我只是尝试为我的 ASP.NET 4.5 Web 窗体应用程序设置 CI/CD,构建应用程序,将文件发布到文件夹并将这些文件复制到 IIS 服务器文件夹。我只停留在构建阶段。如果有人能指导我哪里出错了,我将不胜感激。此外,请任何好的资源来帮助我处理 ASP.NET Web 表单应用程序的整个 CI/CD。
答: 暂无答案
评论
dotnet restore
msbuild -t:restore