Appveyor - .NET MVC 和 NodeJS 构建
Appveyor - .NET MVC and NodeJS build
我有 .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 安装阶段,然后 return 404 或
+ npm install
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN tar EN...2\package.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
我一辈子都弄不明白发生了什么。
如何执行 npm install 和 npm build,同时构建我的 .NET 解决方案
将- ps: npm install
替换为- cmd: npm install
或简单的- npm install
。 npm
将输出写入 stdErr
,这使得 AppVeyor 上的自定义 PowerShell 主机不满意。
如果您的 package.json
文件 不是 在您存储库的根目录下,那么请尝试将您的 - ps: npm install
脚本更改为 - ps: npm install ./src/folder1
(其中 src/folder1
是包含您的 package.json
文件的文件夹,相对于您的存储库的根目录)。
如果你的 package.json
是 在你的存储库的根目录然后尝试将你的 - ps: npm install
脚本从 before_build:
部分移动到 install:
部分,以便您的 yml 如下所示:
install:
- ps: Install-Product node $env:nodejs_version
- npm install #or - npm install ./src/folder1
我遇到了与您相同的问题(为托管 Angular 应用程序的 .NET 解决方案构建的 appveyor 需要安装节点包),以上对我有用。
有关 NodeJS 的应用程序文档,请参阅 here。
我有 .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 安装阶段,然后 return 404 或
+ npm install
+ ~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN tar EN...2\package.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
我一辈子都弄不明白发生了什么。
如何执行 npm install 和 npm build,同时构建我的 .NET 解决方案
将- ps: npm install
替换为- cmd: npm install
或简单的- npm install
。 npm
将输出写入 stdErr
,这使得 AppVeyor 上的自定义 PowerShell 主机不满意。
如果您的 package.json
文件 不是 在您存储库的根目录下,那么请尝试将您的 - ps: npm install
脚本更改为 - ps: npm install ./src/folder1
(其中 src/folder1
是包含您的 package.json
文件的文件夹,相对于您的存储库的根目录)。
如果你的 package.json
是 在你的存储库的根目录然后尝试将你的 - ps: npm install
脚本从 before_build:
部分移动到 install:
部分,以便您的 yml 如下所示:
install:
- ps: Install-Product node $env:nodejs_version
- npm install #or - npm install ./src/folder1
我遇到了与您相同的问题(为托管 Angular 应用程序的 .NET 解决方案构建的 appveyor 需要安装节点包),以上对我有用。
有关 NodeJS 的应用程序文档,请参阅 here。