首页 > 解决方案 > Appveyor - .NET MVC 和 NodeJS 构建

问题描述

我有 .NET MVC 应用程序,它托管一个 Angular 应用程序。

我需要使用 Appveyor 配置我的构建 yaml 来构建 .NET 解决方案,还需要 cd 进入 Angular 文件夹并执行 npm install 和 npm build。

我的 Appveyor 文件看起来像

# Project configuration
version: $(versionNumber)-{branch}.{build}
# Location of the cloned repo on the build server
clone_folder: c:\projects\something

# Environment Variables
environment: 
  nodejs_version: "8"
  versionNumber: "1.9.0"
  devpackageVersion: "$(versionNumber)-alpha.$(APPVEYOR_BUILD_NUMBER)"
  relpackageVersion: "$(versionNumber).$(APPVEYOR_BUILD_NUMBER)"
  buildFolder: "$(APPVEYOR_BUILD_FOLDER)"

  # Install scripts. (runs after repo cloning)
install:
  # Get the latest stable version of Node.js
  - ps: Install-Product node $env:nodejs_version

# branches to build
branches:
  only:
    - develop
    - /releases.*/
    - /features.*/
    - /bugfixes.*/
    - /hotfixes.*/

# Nuget Restore
nuget:
 # Retrieve packages from account feed
 account_feed: true
 # Retrieve packages from project feed
 project_feed: true

image: Visual Studio 2017

# Build configuration
platform: Any CPU
configuration: Release

# Step to execute before build
before_build:
  # Restore NPM packages
 - ps: cd angular
 - ps: npm install
 - ps: cd ..
  # Restore Nuget packages
 - cmd: nuget restore something.sln -Verbosity quiet

# Step to build the solution
build:
 parallel: true
 # Visual Studio solution to build
 project: something.sln
 verbosity: minimal

# Conditional configuration depending on branch
for:
-
  branches:
    only:
      - develop
      - /features.*/
      - /bugfixes.*/

  # Powershell to pack files for Octopus
  after_build:    
    - ps: octo pack --id=something.something --version="$env:devpackageVersion" --basePath="$env:buildFolder"\something\ --outFolder="$env:buildFolder"\packages\

  # Step to create the artifact in AppVeyor
  artifacts:
    # Path to the packages created above
    - path: 'packages\*.nupkg'

  # Step to orchestrate Octopus Deploy
  deploy:
    - provider: Octopus
      push_packages: true
      create_release: true
      project: something
      create_release_advanced: --releaseNumber=$(devpackageVersion)
      deploy_release: true
      environment: QA
      server: https://something
      api_key: something
      deploy_wait: false
      push_packages_advanced: --ignoreSslErrors

# Conditional configuration depending on branch
-
  branches:
    only:
      - /releases.*/
      - /hotfixes.*/

  # Powershell to pack files for Octopus
  after_build:
    - ps: octo pack --id=something.something --version="$env:relpackageVersion" --basePath="$env:buildFolder"\something\ --outFolder="$env:buildFolder"\packages\

  # Step to create the artifact in AppVeyor
  artifacts:
    # Path to the packages created above
    - path: 'packages\*.nupkg'

  # Step to orchestrate Octopus Deploy
  deploy:
    - provider: Octopus
      push_packages: true
      create_release: true
      project: something
      create_release_advanced: --releaseNumber=$(relpackageVersion)
      deploy_release: true
      environment: QA
      server: https://something
      api_key: something
      deploy_wait: false
      push_packages_advanced: --ignoreSslErrors

然而,这似乎进入了 npm install 阶段,然后返回 404 或

+ npm install
+ ~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (npm WARN tar EN...2\package.json':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

我终其一生都无法弄清楚正在发生的事情。

如何执行 npm install 和 npm build,同时构建我的 .NET 解决方案

标签: .netnode.jsappveyor

解决方案


替换- ps: npm install- cmd: npm install或简单- npm installnpm写入stdErr使 AppVeyor 上的自定义 PowerShell 主机不满意的输出。


推荐阅读