【发布时间】:2021-08-28 08:38:40
【问题描述】:
我正在尝试为 .Net 5 Web 应用程序配置 CI。
此 Web 应用已在本地成功构建,并已发布到 dev、prod。一切都很好。
但是当我尝试通过 Azure Pipeline 构建它时,构建失败并出现错误
Dotnet 命令在以下项目中因非零退出代码而失败
日志错误:
错误 TS2307:构建:找不到模块“@angular/core”或其对应的类型声明。
这是我的 package.json:
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.3.1",
"core-js": "~2.4.1",
"devextreme": "17.1.4",
"devextreme-angular": "~17.1.4",
"jquery": "^3.6.0",
"natives": "^1.1.6",
"rxjs": "^5.4.2",
"ts-helpers": "~1.1.1",
"zone.js": "~0.7.2"
},
"devDependencies": {
"@angular/cli": "1.1.0",
"@angular/compiler-cli": "2.3.1",
"@types/jasmine": "2.5.38",
"@types/jquery": "2.0.46",
"@types/node": "^6.14.9",
"codelyzer": "~2.0.0-beta.1",
"css-loader": "0.28.11",
"del": "^3.0.0",
"gulp": "^4.0.2",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^3.0.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.0.2",
"karma-remap-istanbul": "~0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "~4.3.0",
"typescript": "~2.0.3",
"uglify-js": "^3.6.5"
}
我在 Pipeline 中使用 ASP .Net Core 模板(DotNetCoreCLI@2)。 我该如何解决这个问题?
YAML:
resources:
- repo: self
queue:
name: Default
#Your build pipeline references an undefined variable named ‘Parameters.RestoreBuildProjects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.RestoreBuildProjects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references an undefined variable named ‘Parameters.TestProjects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
steps:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: '$(Parameters.RestoreBuildProjects)'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '$(Parameters.RestoreBuildProjects)'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '$(Parameters.TestProjects)'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
publishWebProjects: True
arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
zipAfterPublish: True
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
【问题讨论】:
-
Angular 主要版本不匹配。你有 CLI v1、路由器 v3 和 rest v2。另外,你能分享一下管道步骤吗?
-
@JSONDerulo 但在本地构建成功。步骤 - 恢复 - 构建 - 测试 - 发布。 “构建”步骤失败。
-
你能提供你的管道代码吗?
-
@DreadedFrost 你的意思是 YAML 吗?
-
是的,请添加 YAML
标签: angular .net-core azure-devops azure-pipelines .net-5