gpt4 book ai didi

.net - Appveyor - .NET MVC 和 NodeJS 构建

转载 作者:太空宇宙 更新时间:2023-11-04 02:45:45 25 4
gpt4 key购买 nike

我有 .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 解决方案

最佳答案

如果您的 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 需要安装 Node 包),以上内容对我有用。

参见here有关 NodeJS 的 appveyor 文档。

关于.net - Appveyor - .NET MVC 和 NodeJS 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50609816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com